Bug 1426627 - Avoid loading sync modules for non-sync users in UnifiedComplete r=florian
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Mon, 08 Jan 2018 17:10:33 -0500
changeset 450218 7b41371e4b3ea65b564d8e0b8edb07be67a13b61
parent 450217 3e88948848f810df2f5af02cbd6ce521b6a4329d
child 450219 f274c8f16f4e1329fefe7f2e1fa408df7fbf3ae4
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1426627
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 1426627 - Avoid loading sync modules for non-sync users in UnifiedComplete r=florian MozReview-Commit-ID: 3e90VbuGv7Z
toolkit/components/places/UnifiedComplete.js
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -325,16 +325,19 @@ XPCOMUtils.defineLazyModuleGetters(this,
   BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
   ProfileAge: "resource://gre/modules/ProfileAge.jsm",
 });
 
 XPCOMUtils.defineLazyServiceGetter(this, "textURIService",
                                    "@mozilla.org/intl/texttosuburi;1",
                                    "nsITextToSubURI");
 
+XPCOMUtils.defineLazyPreferenceGetter(this, "syncUsernamePref",
+                                      "services.sync.username");
+
 function setTimeout(callback, ms) {
   let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
   timer.initWithCallback(callback, ms, timer.TYPE_ONE_SHOT);
   return timer;
 }
 
 function convertBucketsCharPrefToArray(str) {
   return str.split(",")
@@ -1675,16 +1678,20 @@ Search.prototype = {
     // results, we add a timeout racing with the addition.
     let timeoutPromise = new Promise(resolve => {
       setTimeout(resolve, MAXIMUM_ALLOWED_EXTENSION_TIME_MS);
     });
     return Promise.race([timeoutPromise, promise]).catch(Cu.reportError);
   },
 
   async _matchRemoteTabs() {
+    // Bail out early for non-sync users.
+    if (!syncUsernamePref) {
+      return;
+    }
     let matches = await PlacesRemoteTabsAutocompleteProvider.getMatches(this._originalSearchString);
     for (let {url, title, icon, deviceName} of matches) {
       // It's rare that Sync supplies the icon for the page (but if it does, it
       // is a string URL)
       if (!icon) {
         icon = "page-icon:" + url;
       } else {
         icon = PlacesUtils.favicons