From a8155ea5720ddae477497acf6dc8d9ae773d6129 Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Thu, 8 Jan 2015 15:47:51 +1100 Subject: [PATCH] Bug 1119078 - only pre-fetch the sync migration sentinel if using a legacy identity. r=rnewman --- services/sync/modules/browserid_identity.js | 10 ++++++++++ services/sync/modules/identity.js | 16 ++++++++++++++++ services/sync/modules/service.js | 8 ++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/services/sync/modules/browserid_identity.js b/services/sync/modules/browserid_identity.js index 8262e0b645a..e5eaa38877f 100644 --- a/services/sync/modules/browserid_identity.js +++ b/services/sync/modules/browserid_identity.js @@ -399,6 +399,16 @@ this.BrowserIDManager.prototype = { this._shouldHaveSyncKeyBundle = false; }, + /** + * Pre-fetches any information that might help with migration away from this + * identity. Called after every sync and is really just an optimization that + * allows us to avoid a network request for when we actually need the + * migration info. + */ + prefetchMigrationSentinel: function(service) { + // nothing to do here until we decide to migrate away from FxA. + }, + /** * Return credentials hosts for this identity only. */ diff --git a/services/sync/modules/identity.js b/services/sync/modules/identity.js index 22fadb02785..2bee13b5b81 100644 --- a/services/sync/modules/identity.js +++ b/services/sync/modules/identity.js @@ -446,6 +446,22 @@ IdentityManager.prototype = { return this.username && this.basicPassword && true; }, + /** + * Pre-fetches any information that might help with migration away from this + * identity. Called after every sync and is really just an optimization that + * allows us to avoid a network request for when we actually need the + * migration info. + */ + prefetchMigrationSentinel: function(service) { + // Try and fetch the migration sentinel - it will end up in the recordManager + // cache. + try { + service.recordManager.get(service.storageURL + "meta/fxa_credentials"); + } catch (ex) { + this._log.warn("Failed to pre-fetch the migration sentinel", ex); + } + }, + /** * Obtains the array of basic logins from nsiPasswordManager. */ diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index fa3e659d526..88b68505f7d 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -1281,12 +1281,12 @@ Sync11Service.prototype = { histogram.add(1); // We successfully synchronized. - // Try and fetch the migration sentinel - it will end up in the recordManager - // cache, so a sync migration doesn't need a server round-trip. + // Check if the identity wants to pre-fetch a migration sentinel from + // the server. // If we have no clusterURL, we are probably doing a node reassignment - // do don't attempt to get the credentials. + // so don't attempt to get it in that case. if (this.clusterURL) { - this.recordManager.get(this.storageURL + "meta/fxa_credentials"); + this.identity.prefetchMigrationSentinel(this); } // Now let's update our declined engines.