Bug 784759 - Move database creation out of startup on firstrun. r=mfinkle
☠☠ backed out by 64a0ab78b261 ☠ ☠
authorWes Johnston <wjohnston@mozilla.com>
Mon, 05 Nov 2012 17:14:20 -0800
changeset 112383 0b25e27d0a354ddcafbd6fd248f92337dfa1ba7e
parent 112382 5266d6af1b81810587e864a6a84c5c83a1c57375
child 112384 0d4e09ade3368bfa95e66c514bfe31271daafecb
push id23812
push useremorley@mozilla.com
push dateTue, 06 Nov 2012 14:01:34 +0000
treeherdermozilla-central@f4aeed115e54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs784759
milestone19.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 784759 - Move database creation out of startup on firstrun. r=mfinkle
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -278,18 +278,28 @@ var BrowserApp = {
     event.initEvent("UIReady", true, false);
     window.dispatchEvent(event);
 
     let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
     if (ss.shouldRestore()) {
       this.restoreSession(false, null);
     }
 
-    if (updated)
-      this.onAppUpdated();
+    if (updated) {
+        // creating the form history and passwords databases can be expensive
+        // delay it until after the first page has loaded
+        let browser = BrowserApp.selectedTab.browser;
+        let updatedFun = function updatedFun() {
+            browser.removeEventListener("DOMContentLoaded", updatedFun, false);
+            // initialize the form history and passwords databases on upgrades
+            Services.obs.notifyObservers(null, "FormHistory:Init", "");
+            Services.obs.notifyObservers(null, "Passwords:Init", "");
+        }
+        browser.addEventListener("DOMContentLoaded", updatedFun, false);
+    }
 
     // notify java that gecko has loaded
     sendMessageToJava({
       gecko: {
         type: "Gecko:Ready"
       }
     });
 
@@ -482,22 +492,16 @@ var BrowserApp = {
            contentDisposition = "";
            type = "";
         }
         ContentAreaUtils.internalSave(aTarget.currentURI.spec, null, null, contentDisposition, type, false, "SaveImageTitle", null,
                                       aTarget.ownerDocument.documentURIObject, aTarget.ownerDocument, true, null);
       });
   },
 
-  onAppUpdated: function() {
-    // initialize the form history and passwords databases on upgrades
-    Services.obs.notifyObservers(null, "FormHistory:Init", "");
-    Services.obs.notifyObservers(null, "Passwords:Init", "");
-  },
-
   shutdown: function shutdown() {
     NativeWindow.uninit();
     SelectionHandler.uninit();
     LightWeightThemeWebInstaller.uninit();
     FormAssistant.uninit();
     FindHelper.uninit();
     OfflineApps.uninit();
     IndexedDB.uninit();