Bug 1424161 - Track hasSyncedThisSession properly in SyncedTabs.jsm. r?markh
MozReview-Commit-ID: 4e4QSzMbeXx
--- a/services/sync/modules/SyncedTabs.jsm
+++ b/services/sync/modules/SyncedTabs.jsm
@@ -204,16 +204,19 @@ let SyncedTabsInternal = {
return true;
}
let engine = Weave.Service.engineManager.get("tabs");
return engine && engine.enabled;
},
get hasSyncedThisSession() {
+ if (Weave.Service.hasSyncedThisSession) {
+ return true;
+ }
let engine = Weave.Service.engineManager.get("tabs");
return engine && engine.hasSyncedThisSession;
},
};
Services.obs.addObserver(SyncedTabsInternal, "weave:engine:sync:finish");
Services.obs.addObserver(SyncedTabsInternal, "weave:service:start-over");
// Observe the pref the indicates the state of the tabs engine has changed.
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -90,16 +90,22 @@ Sync11Service.prototype = {
infoURL: null,
storageURL: null,
metaURL: null,
cryptoKeyURL: null,
// The cluster URL comes via the ClusterManager object, which in the FxA
// world is ebbedded in the token returned from the token server.
_clusterURL: null,
+ // A flag to indicate if we have synced in this session. This is to help
+ // consumers of remote tabs that may want to differentiate between "I've an
+ // empty tab list as I haven't yet synced" vs "I've an empty tab list
+ // as there really are no tabs"
+ hasSyncedThisSession: false,
+
get clusterURL() {
return this._clusterURL || "";
},
set clusterURL(value) {
if (value != null && typeof value != "string") {
throw new Error("cluster must be a string, got " + (typeof value));
}
this._clusterURL = value;
@@ -807,16 +813,17 @@ Sync11Service.prototype = {
this.collectionKeys.clear();
this.status.resetBackoff();
// Reset Weave prefs.
this._ignorePrefObserver = true;
Svc.Prefs.resetBranch("");
this._ignorePrefObserver = false;
this.clusterURL = null;
+ this.hasSyncedThisSession = false;
Svc.Prefs.set("lastversion", WEAVE_VERSION);
this.identity.deleteSyncCredentials();
try {
this.identity.finalize();
this.status.__authManager = null;
@@ -1109,16 +1116,17 @@ Sync11Service.prototype = {
return this._lock("service.js: sync",
this._notify("sync", JSON.stringify({why}), async function onNotify() {
let histogram = Services.telemetry.getHistogramById("WEAVE_START_COUNT");
histogram.add(1);
let synchronizer = new EngineSynchronizer(this);
await synchronizer.sync(engineNamesToSync, why); // Might throw!
+ this.hasSyncedThisSession = true;
histogram = Services.telemetry.getHistogramById("WEAVE_COMPLETE_SUCCESS_COUNT");
histogram.add(1);
// We successfully synchronized.
// 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