From 30a5a5e09529e6d2adda88c5a3e994ac277a2aa8 Mon Sep 17 00:00:00 2001 From: Edward Lee Date: Tue, 15 Dec 2009 14:21:12 -0800 Subject: [PATCH] Bug 534944 - Avoid loading/importing weave files until necessary to speed up fennec startup Have importing service.js trigger startup instead of only starting up from Weave.js, which now is used as a backup kickstarter. Only call import(service.js) when necessary from various Fennec files. --- services/sync/Weave.js | 9 +++++++-- services/sync/modules/service.js | 5 +++-- services/sync/modules/util.js | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/services/sync/Weave.js b/services/sync/Weave.js index 6db75d883eaa..cfa151d25e7a 100644 --- a/services/sync/Weave.js +++ b/services/sync/Weave.js @@ -59,8 +59,13 @@ WeaveService.prototype = { break; case "final-ui-startup": - Cu.import("resource://weave/service.js"); - Weave.Service.onStartup(); + // Force Weave service to load if it hasn't triggered from overlays + this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); + this.timer.initWithCallback({ + notify: function() { + Cu.import("resource://weave/service.js"); + } + }, 10000, Ci.nsITimer.TYPE_ONE_SHOT); break; } } diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index 5dd827c6de7f..47cf262f1ec5 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -253,8 +253,6 @@ WeaveSvc.prototype = { while (enum.hasMoreElements()) wait += enum.getNext().gBrowser.mTabs.length; break; - case FENNEC_ID: - wait = 10; } // Make sure we wait a little but but not too long in the worst case @@ -1523,3 +1521,6 @@ WeaveSvc.prototype = { } }, }; + +// Load Weave on the first time this file is loaded +Weave.Service.onStartup(); diff --git a/services/sync/modules/util.js b/services/sync/modules/util.js index 2c45580d4770..6c94b6f1584a 100644 --- a/services/sync/modules/util.js +++ b/services/sync/modules/util.js @@ -795,6 +795,7 @@ let Utils = { let Svc = {}; Svc.Prefs = new Preferences(PREFS_BRANCH); +Svc.Obs = Observers; [["Annos", "@mozilla.org/browser/annotation-service;1", "nsIAnnotationService"], ["AppInfo", "@mozilla.org/xre/app-info;1", "nsIXULAppInfo"], ["Bookmark", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService"],