Bug 1388145 - Move Services.logins initialization to nsBrowserGlue. r=MattN draft
authorFelipe Gomes <felipc@gmail.com>
Wed, 09 Aug 2017 15:43:25 -0300
changeset 643424 85f4e26d727a042091c5a8e5f9b9c346604d6029
parent 643423 e047cfb5415658d732359e569f42572e0fb40bec
child 643425 ababa118265f4257bcd397cfd811be41981782fc
push id73095
push userfelipc@gmail.com
push dateWed, 09 Aug 2017 18:46:00 +0000
reviewersMattN
bugs1388145
milestone57.0a1
Bug 1388145 - Move Services.logins initialization to nsBrowserGlue. r=MattN This will move this code to a place that will run it once per session (as needed) and not once per window. It also better defines it to run after all sessionstore-windows-restored, instead of arbitrarly after 3 seconds. MozReview-Commit-ID: 2ekVeZfRYC4
browser/base/content/browser.js
browser/components/nsBrowserGlue.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1638,28 +1638,16 @@ var gBrowserInit = {
         DownloadsCommon.initializeAllDataLinks();
         Cu.import("resource:///modules/DownloadsTaskbar.jsm", {})
           .DownloadsTaskbar.registerIndicator(window);
       } catch (ex) {
         Cu.reportError(ex);
       }
     }, 10000);
 
-    // Load the Login Manager data from disk off the main thread, some time
-    // after startup.  If the data is required before the timeout, for example
-    // because a restored page contains a password field, it will be loaded on
-    // the main thread, and this initialization request will be ignored.
-    setTimeout(function() {
-      try {
-        Services.logins;
-      } catch (ex) {
-        Cu.reportError(ex);
-      }
-    }, 3000);
-
     // The object handling the downloads indicator is also initialized here in the
     // delayed startup function, but the actual indicator element is not loaded
     // unless there are downloads to be displayed.
     DownloadsButton.initializeIndicator();
 
     if (AppConstants.platform != "macosx") {
       updateEditUIVisibility();
       let placesContext = document.getElementById("placesContext");
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1128,16 +1128,28 @@ BrowserGlue.prototype = {
    * but it will not make it happen later (and out of order) compared
    * to the other ones scheduled together.
    */
   _scheduleStartupIdleTasks() {
     Services.tm.idleDispatchToMainThread(() => {
       ContextualIdentityService.load();
     });
 
+    // Load the Login Manager data from disk off the main thread, some time
+    // after startup.  If the data is required before this runs, for example
+    // because a restored page contains a password field, it will be loaded on
+    // the main thread, and this initialization request will be ignored.
+    Services.tm.idleDispatchToMainThread(() => {
+      try {
+        Services.logins;
+      } catch (ex) {
+        Cu.reportError(ex);
+      }
+    }, 3000);
+
     // It's important that SafeBrowsing is initialized reasonably
     // early, so we use a maximum timeout for it.
     Services.tm.idleDispatchToMainThread(() => {
       SafeBrowsing.init();
     }, 5000);
 
     if (AppConstants.MOZ_CRASHREPORTER) {
       Services.tm.idleDispatchToMainThread(() => {