From 77783a1c0f4eb4cade000b4a059680649d9deb6b Mon Sep 17 00:00:00 2001 From: "dietrich@mozilla.com" Date: Thu, 17 Jan 2008 22:58:52 -0800 Subject: [PATCH] Bug 382711 - on migration or db upgrade of a profile with livemarks, we start up the livemark service' update timer (r=sspitzer) --- browser/base/content/browser.js | 7 +++++++ .../places/public/nsILivemarkService.idl | 9 ++++++++- .../components/places/src/nsLivemarkService.js | 16 ++++++++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index e0a4ebd72a7e..58d098ff0d45 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1049,6 +1049,13 @@ function delayedStartup() // themselves. gBrowser.addEventListener("command", BrowserOnCommand, false); + // Delayed initialization of the livemarks update timer. + // Livemark updates don't need to start until after bookmark UI + // such as the toolbar has initialized. Starting 5 seconds after + // delayedStartup in order to stagger this before the download + // manager starts (see below). + setTimeout(function() PlacesUtils.livemarks.start(), 5000); + // Initialize the download manager some time after the app starts so that // auto-resume downloads begin (such as after crashing or quitting with // active downloads) and speeds up the first-load of the download manager UI. diff --git a/toolkit/components/places/public/nsILivemarkService.idl b/toolkit/components/places/public/nsILivemarkService.idl index fbee1496f7e3..09375a0264c7 100644 --- a/toolkit/components/places/public/nsILivemarkService.idl +++ b/toolkit/components/places/public/nsILivemarkService.idl @@ -42,9 +42,16 @@ interface nsIURI; interface nsINavBookmarksService; -[scriptable, uuid(602e3a71-2d10-4d8f-80c2-6db302b5c89d)] +[scriptable, uuid(7879747e-8871-4a7b-9032-5c4fff1d6017)] interface nsILivemarkService : nsISupports { + /** + * Starts the livemark refresh timer. + * Being able to manually control this allows activity such + * as bookmarks import to occur without kicking off HTTP traffic. + */ + void start(); + /** * Creates a new livemark * @param folder The id of the parent folder diff --git a/toolkit/components/places/src/nsLivemarkService.js b/toolkit/components/places/src/nsLivemarkService.js index 33b861502f0d..ece6c50e2524 100644 --- a/toolkit/components/places/src/nsLivemarkService.js +++ b/toolkit/components/places/src/nsLivemarkService.js @@ -147,8 +147,6 @@ function LivemarkService() { new G_ObserverServiceObserver('xpcom-shutdown', BindToObject(this._shutdown, this), true /*only once*/); - new G_Alarm(BindToObject(this._fireTimer, this), LIVEMARK_TIMEOUT, - true /* repeat */); if (IS_CONTRACTID in Cc) this._idleService = Cc[IS_CONTRACTID].getService(Ci.nsIIdleService); @@ -183,6 +181,14 @@ LivemarkService.prototype = { return this.__history; }, + _updateTimer: null, + start: function LS_start() { + if (this._updateTimer) + return; + this._updateTimer = new G_Alarm(BindToObject(this._fireTimer, this), + LIVEMARK_TIMEOUT, true /* repeat */); + }, + // returns new length of _livemarks _pushLivemark: function LS__pushLivemark(folderId, feedURI) { return this._livemarks.push({folderId: folderId, feedURI: feedURI}); @@ -204,6 +210,12 @@ LivemarkService.prototype = { if (livemark.loadGroup) livemark.loadGroup.cancel(NS_BINDING_ABORTED); } + + // kill timer + if (this._updateTimer) { + this._updateTimer.cancel(); + this._updateTimer = null; + } }, _fireTimer: function LS__fireTimer() {