summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_updater.h
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/extension_updater.h')
-rw-r--r--chrome/browser/extensions/extension_updater.h22
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);