Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(853)

Unified Diff: chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h

Issue 1897293005: Rate limit programmatic update checks for extensions (reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: have Get() just return the net::BackoffEntry::Policy directly 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h
diff --git a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h
index 934bcd84a95c86bd43471d2425941dc5391f6ac4..6ff1a05aef213e2301a6b1664bfa3dda6331f1a5 100644
--- a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h
+++ b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h
@@ -6,15 +6,19 @@
#define CHROME_BROWSER_EXTENSIONS_API_RUNTIME_CHROME_RUNTIME_API_DELEGATE_H_
#include <map>
-#include <vector>
+#include <string>
+#include <utility>
#include "base/macros.h"
+#include "base/scoped_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/api/runtime/runtime_api.h"
#include "extensions/browser/api/runtime/runtime_api_delegate.h"
+#include "extensions/browser/extension_registry_observer.h"
namespace base {
+class TickClock;
class TimeTicks;
}
@@ -25,16 +29,21 @@ class NotificationSource;
}
namespace extensions {
+class ExtensionRegistry;
class RuntimeAPI;
class UpdateObserver;
}
class ChromeRuntimeAPIDelegate : public extensions::RuntimeAPIDelegate,
- public content::NotificationObserver {
+ public content::NotificationObserver,
+ public extensions::ExtensionRegistryObserver {
public:
explicit ChromeRuntimeAPIDelegate(content::BrowserContext* context);
~ChromeRuntimeAPIDelegate() override;
+ // Sets a custom TickClock to use in tests.
+ static void set_tick_clock_for_tests(base::TickClock* clock);
+
private:
friend class extensions::RuntimeAPI;
@@ -56,6 +65,11 @@ class ChromeRuntimeAPIDelegate : public extensions::RuntimeAPIDelegate,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
+ // ExtensionRegistryObserver implementation.
+ void OnExtensionInstalled(content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ bool is_update) override;
+
void UpdateCheckComplete(const std::string& extension_id);
void CallUpdateCallbacks(const std::string& extension_id,
const UpdateCheckResult& result);
@@ -73,12 +87,14 @@ class ChromeRuntimeAPIDelegate : public extensions::RuntimeAPIDelegate,
// it was reloaded with not enough time in between reloads.
std::map<std::string, std::pair<base::TimeTicks, int> > last_reload_time_;
- // Pending update checks.
- typedef std::vector<UpdateCheckCallback> UpdateCallbackList;
- typedef std::map<std::string, UpdateCallbackList> UpdateCallbackMap;
- UpdateCallbackMap pending_update_checks_;
+ // Information about update checks, keyed by extension id.
+ struct UpdateCheckInfo;
+ std::map<std::string, UpdateCheckInfo> update_check_info_;
+
+ ScopedObserver<extensions::ExtensionRegistry,
+ extensions::ExtensionRegistryObserver>
+ extension_registry_observer_;
- private:
DISALLOW_COPY_AND_ASSIGN(ChromeRuntimeAPIDelegate);
};
« no previous file with comments | « no previous file | chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698