Bug 1119078 - only pre-fetch the sync migration sentinel if using a legacy identity. r=rnewman
--- a/services/sync/modules/browserid_identity.js
+++ b/services/sync/modules/browserid_identity.js
@@ -395,16 +395,26 @@ this.BrowserIDManager.prototype = {
resetSyncKey: function() {
this._syncKey = null;
this._syncKeyBundle = null;
this._syncKeyUpdated = true;
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.
*/
_getSyncCredentialsHosts: function() {
return Utils.getSyncCredentialsHostsFxA();
},
/**
* The current state of the auth credentials.
--- a/services/sync/modules/identity.js
+++ b/services/sync/modules/identity.js
@@ -442,16 +442,32 @@ IdentityManager.prototype = {
},
hasBasicCredentials: function hasBasicCredentials() {
// Because JavaScript.
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.
*/
_getLogins: function _getLogins(realm) {
return Services.logins.findLogins({}, PWDMGR_HOST, null, realm);
},
/**
* Set a login in the password manager.
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -1276,22 +1276,22 @@ Sync11Service.prototype = {
// wait() throws if the first argument is truthy, which is exactly what
// we want.
let result = cb.wait();
histogram = Services.telemetry.getHistogramById("WEAVE_COMPLETE_SUCCESS_COUNT");
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.
let meta = this.recordManager.get(this.metaURL);
if (!meta) {
this._log.warn("No meta/global; can't update declined state.");
return;
}