Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: chrome/browser/extensions/updater/extension_updater.h

Issue 1903713002: Revert of Rate limit programmatic update checks for extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/updater/extension_updater.h
diff --git a/chrome/browser/extensions/updater/extension_updater.h b/chrome/browser/extensions/updater/extension_updater.h
index 92851e8c351fb8c2f26e6ec63bc845454399e542..d2568296e1b6fc520220de2e2b083c9269d51ea7 100644
--- a/chrome/browser/extensions/updater/extension_updater.h
+++ b/chrome/browser/extensions/updater/extension_updater.h
@@ -56,6 +56,7 @@
// ....
// updater->Stop();
class ExtensionUpdater : public ExtensionDownloaderDelegate,
+ public ExtensionRegistryObserver,
public content::NotificationObserver {
public:
typedef base::Closure FinishedCallback;
@@ -103,8 +104,10 @@
// already a pending task that has not yet run.
void CheckSoon();
- // Starts an update check for the specified extension soon.
- void CheckExtensionSoon(const std::string& extension_id,
+ // Starts an update check for the specified extension soon. If a check
+ // is already running, or finished too recently without an update being
+ // installed, this method returns false and the check won't be scheduled.
+ bool CheckExtensionSoon(const std::string& extension_id,
const FinishedCallback& callback);
// Starts an update check right now, instead of waiting for the next
@@ -154,6 +157,8 @@
// The ids of extensions that have in-progress update checks.
std::list<std::string> in_progress_ids_;
};
+
+ struct ThrottleInfo;
// Ensure that we have a valid ExtensionDownloader instance referenced by
// |downloader|.
@@ -209,6 +214,12 @@
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
+ // Implementation of ExtensionRegistryObserver.
+ void OnExtensionWillBeInstalled(content::BrowserContext* browser_context,
+ const Extension* extension,
+ bool is_update,
+ const std::string& old_name) override;
+
// Send a notification that update checks are starting.
void NotifyStarted();
@@ -245,6 +256,9 @@
// Observes CRX installs we initiate.
content::NotificationRegistrar registrar_;
+ ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+ extension_registry_observer_;
+
// True when a CrxInstaller is doing an install. Used in MaybeUpdateCrxFile()
// to keep more than one install from running at once.
bool crx_install_is_running_;
@@ -255,6 +269,10 @@
ExtensionCache* extension_cache_;
+ // Keeps track of when an extension tried to update itself, so we can throttle
+ // checks to prevent too many requests from being made.
+ std::map<std::string, ThrottleInfo> throttle_info_;
+
base::WeakPtrFactory<ExtensionUpdater> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ExtensionUpdater);
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/updater/extension_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698