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
--- 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(() => {