Bug 1388145 - Move ContextualIdentityService and SafeBrowsing initialization to _scheduleStartupIdleTasks. r=florian draft
authorFelipe Gomes <felipc@gmail.com>
Wed, 09 Aug 2017 15:06:30 -0300
changeset 643405 08ee589ee7b88fc78dbd106c6f3f191c5fe2e928
parent 643404 0dddf6768dea0fd0d044f0433f1fa869a92aa19b
child 643406 e317326c3dc4a47f87ba86b29dc3dbdec2657f33
push id73092
push userfelipc@gmail.com
push dateWed, 09 Aug 2017 18:36:00 +0000
reviewersflorian
bugs1388145
milestone57.0a1
Bug 1388145 - Move ContextualIdentityService and SafeBrowsing initialization to _scheduleStartupIdleTasks. r=florian This has no change in behavior since they are already scheduled with idleDispatchToMainThread, but this puts them in the proper code location MozReview-Commit-ID: IS5ZQjJy77q
browser/components/nsBrowserGlue.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1181,25 +1181,16 @@ BrowserGlue.prototype = {
 
     if (AppConstants.MOZ_CRASHREPORTER) {
       UnsubmittedCrashHandler.init();
       Services.tm.idleDispatchToMainThread(function() {
         UnsubmittedCrashHandler.checkForUnsubmittedCrashReports();
       });
     }
 
-    // Let's load the contextual identities.
-    Services.tm.idleDispatchToMainThread(() => {
-      ContextualIdentityService.load();
-    });
-
-    Services.tm.idleDispatchToMainThread(() => {
-      SafeBrowsing.init();
-    }, 5000);
-
     this._sanitizer.onStartup();
     E10SAccessibilityCheck.onWindowsRestored();
 
     this._scheduleStartupIdleTasks();
 
     this._lateTasksIdleObserver = (idleService, topic, data) => {
       if (topic == "idle") {
         idleService.removeIdleObserver(this._lateTasksIdleObserver,
@@ -1228,17 +1219,25 @@ BrowserGlue.prototype = {
    * _scheduleArbitrarilyLateIdleTasks.
    * Don't be fooled by thinking that the use of the timeout parameter
    * will delay your function: it will just ensure that it potentially
    * happens _earlier_ than expected (when the timeout limit has been reached),
    * but it will not make it happen later (and out of order) compared
    * to the other ones scheduled together.
    */
   _scheduleStartupIdleTasks() {
-    // TODO: Functions to be added here with Services.tm.idleDispatchToMainThread
+    Services.tm.idleDispatchToMainThread(() => {
+      ContextualIdentityService.load();
+    });
+
+    // It's important that SafeBrowsing is initialized reasonably
+    // early, so we use a maximum timeout for it.
+    Services.tm.idleDispatchToMainThread(() => {
+      SafeBrowsing.init();
+    }, 5000);
   },
 
   /**
    * Use this function as an entry point to schedule tasks that need
    * to run once per session, at any arbitrary point in time.
    * This function will be called from an idle observer. Check the value of
    * LATE_TASKS_IDLE_TIME_SEC to see the current value for this idle
    * observer.