Bug 1427850 - Check that sync is ready directly instead of reading the sync username to determine it r=markh
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Wed, 03 Jan 2018 15:22:43 -0500
changeset 397791 fcec2e929c2ca950a5cca97d3d8d308fa12e4213
parent 397790 862df5b1a0c918377a22540460538d52f9cda2e1
child 397792 c0eeabce1fd89e90d19d4d7df9c02a8efd0fca93
push id57544
push usertchiovoloni@mozilla.com
push dateThu, 04 Jan 2018 19:32:02 +0000
treeherderautoland@fcec2e929c2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs1427850
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1427850 - Check that sync is ready directly instead of reading the sync username to determine it r=markh MozReview-Commit-ID: LnQ6Em0GCvM
services/sync/Weave.js
toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
--- a/services/sync/Weave.js
+++ b/services/sync/Weave.js
@@ -9,18 +9,17 @@ const Cu = Components.utils;
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
                                   "resource://gre/modules/FileUtils.jsm");
 XPCOMUtils.defineLazyGetter(this, "Utils", () => {
   return Cu.import("resource://services-sync/util.js", {}).Utils;
 });
 
-const SYNC_PREFS_BRANCH = "services.sync.";
-
+XPCOMUtils.defineLazyPreferenceGetter(this, "syncUsername", "services.sync.username");
 
 /**
  * Sync's XPCOM service.
  *
  * It is named "Weave" for historical reasons.
  *
  * It's worth noting how Sync is lazily loaded. We register a timer that
  * loads Sync a few seconds after app startup. This is so Sync does not
@@ -123,18 +122,17 @@ WeaveService.prototype = {
    * Whether Sync appears to be enabled.
    *
    * This returns true if we have an associated FxA account
    *
    * It does *not* perform a robust check to see if the client is working.
    * For that, you'll want to check Weave.Status.checkSetup().
    */
   get enabled() {
-    let prefs = Services.prefs.getBranch(SYNC_PREFS_BRANCH);
-    return prefs.prefHasUserValue("username");
+    return !!syncUsername;
   }
 };
 
 function AboutWeaveLog() {}
 AboutWeaveLog.prototype = {
   classID: Components.ID("{d28f8a0b-95da-48f4-b712-caf37097be41}"),
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule,
--- a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
+++ b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
@@ -111,18 +111,17 @@ Services.obs.addObserver(observe, "weave
 Services.prefs.addObserver(PREF_SHOW_REMOTE_ICONS, observe);
 observe(null, "nsPref:changed", PREF_SHOW_REMOTE_ICONS);
 
 // This public object is a static singleton.
 this.PlacesRemoteTabsAutocompleteProvider = {
   // a promise that resolves with an array of matching remote tabs.
   getMatches(searchString) {
     // If Sync isn't configured we bail early.
-    if (Weave === null ||
-        !Services.prefs.prefHasUserValue("services.sync.username")) {
+    if (!weaveXPCService.ready || !weaveXPCService.enabled) {
       return Promise.resolve([]);
     }
 
     let re = new RegExp(escapeRegExp(searchString), "i");
     let matches = [];
     let { tabs, clients } = ensureItems();
     for (let [url, { clientId, tab }] of tabs) {
       let title = tab.title;