diff options
author | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 17:54:34 +0000 |
---|---|---|
committer | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 17:54:34 +0000 |
commit | 951073ea674d8436fbcfbd6a0310fe20fb2e6a4a (patch) | |
tree | 21e794f5116c4bb59174b754920c7cccdcb72639 /chrome/browser/extensions/extension_updater.h | |
parent | de5a586ec7ca9cbbc45953ef5485cff7d8c8c4f3 (diff) | |
download | chromium_src-951073ea674d8436fbcfbd6a0310fe20fb2e6a4a.zip chromium_src-951073ea674d8436fbcfbd6a0310fe20fb2e6a4a.tar.gz chromium_src-951073ea674d8436fbcfbd6a0310fe20fb2e6a4a.tar.bz2 |
Make extensions auto-update schedule persist across browser restarts.
Instead of starting the timer all over again, we instead persist some
information about when we had scheduled it and when it actually fired. We then
try to balance keeping clients reasonably up to date with avoiding a
thundering herd against servers.
BUG=http://crbug.com/12545
TEST=none
Review URL: http://codereview.chromium.org/160433
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22286 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_updater.h')
-rw-r--r-- | chrome/browser/extensions/extension_updater.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/chrome/browser/extensions/extension_updater.h b/chrome/browser/extensions/extension_updater.h index 3973b4e..52b4542 100644 --- a/chrome/browser/extensions/extension_updater.h +++ b/chrome/browser/extensions/extension_updater.h @@ -25,10 +25,12 @@ class Extension; class ExtensionUpdaterTest; class MessageLoop; class ExtensionUpdaterFileHandler; +class PrefService; // A class for doing auto-updates of installed Extensions. Used like this: // // ExtensionUpdater* updater = new ExtensionUpdater(my_extensions_service, +// pref_service, // update_frequency_secs, // file_io_loop); // updater.Start(); @@ -42,16 +44,13 @@ class ExtensionUpdater // extensions and installing updated ones. The |frequency_seconds| parameter // controls how often update checks are scheduled. ExtensionUpdater(ExtensionUpdateService* service, + PrefService* prefs, int frequency_seconds, MessageLoop* file_io_loop); virtual ~ExtensionUpdater(); - // Starts the updater running, with the first check scheduled for - // |frequency_seconds| from now. Eventually ExtensionUpdater will persist the - // time the last check happened, and do the first check |frequency_seconds_| - // from then (potentially adding a short wait if the browser just started). - // (http://crbug.com/12545). + // Starts the updater running. void Start(); // Stops the updater running, cancelling any outstanding update manifest and @@ -107,6 +106,9 @@ class ExtensionUpdater // Does common work from constructors. void Init(); + // Computes when to schedule the first update check. + base::TimeDelta DetermineFirstCheckDelay(); + // URLFetcher::Delegate interface. virtual void OnURLFetchComplete(const URLFetcher* source, const GURL& url, @@ -132,6 +134,12 @@ class ExtensionUpdater // Callback for when ExtensionsService::Install is finished. void OnExtensionInstallFinished(const FilePath& path, Extension* extension); + // Sets the timer to call TimerFired after roughly |target_delay| from now. + // To help spread load evenly on servers, this method adds some random + // jitter. It also saves the scheduled time so it can be reloaded on + // browser restart. + void ScheduleNextCheck(const base::TimeDelta& target_delay); + // BaseTimer::ReceiverMethod callback. void TimerFired(); @@ -167,12 +175,14 @@ class ExtensionUpdater // Pointer back to the service that owns this ExtensionUpdater. ExtensionUpdateService* service_; - base::RepeatingTimer<ExtensionUpdater> timer_; + base::OneShotTimer<ExtensionUpdater> timer_; int frequency_seconds_; // The MessageLoop where we should do file I/O. MessageLoop* file_io_loop_; + PrefService* prefs_; + scoped_refptr<ExtensionUpdaterFileHandler> file_handler_; DISALLOW_COPY_AND_ASSIGN(ExtensionUpdater); |