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

Unified Diff: chrome/browser/extensions/chrome_content_verifier_delegate.h

Issue 2533873003: Add throttling to corrupt policy extensions reinstall (Closed)
Patch Set: ready for review Created 4 years, 1 month 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/chrome_content_verifier_delegate.h
diff --git a/chrome/browser/extensions/chrome_content_verifier_delegate.h b/chrome/browser/extensions/chrome_content_verifier_delegate.h
index f889170e944d17dc1aac17d025e4f154aa9bcf2d..1d7e21808885e6fb28e9d8735cd81d90614be34a 100644
--- a/chrome/browser/extensions/chrome_content_verifier_delegate.h
+++ b/chrome/browser/extensions/chrome_content_verifier_delegate.h
@@ -5,9 +5,12 @@
#ifndef CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_
#define CHROME_BROWSER_EXTENSIONS_CHROME_CONTENT_VERIFIER_DELEGATE_H_
+#include <map>
+#include <memory>
#include <set>
#include <string>
+#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "extensions/browser/content_verifier_delegate.h"
@@ -15,6 +18,10 @@ namespace content {
class BrowserContext;
}
+namespace net {
+class BackoffEntry;
+}
+
namespace extensions {
class ChromeContentVerifierDelegate : public ContentVerifierDelegate {
@@ -35,10 +42,23 @@ class ChromeContentVerifierDelegate : public ContentVerifierDelegate {
void VerifyFailed(const std::string& extension_id,
ContentVerifyJob::FailureReason reason) override;
+ protected:
+ FRIEND_TEST_ALL_PREFIXES(ContentVerifierPolicyTest, Backoff);
+ // For tests, overrides the default action to take to initiate policy
+ // force-reinstalls.
+ static void set_policy_reinstall_action_for_test(
+ base::Callback<void(base::TimeDelta delay)> action);
+
private:
content::BrowserContext* context_;
ContentVerifierDelegate::Mode default_mode_;
+ // This maps an extension id to a backoff entry for slowing down
+ // redownload/reinstall of corrupt policy extensions if it keeps happening
+ // in a loop (eg crbug.com/661738).
+ std::map<std::string, std::unique_ptr<net::BackoffEntry>>
+ policy_reinstall_backoff_;
+
// For reporting metrics in BOOTSTRAP mode, when an extension would be
// disabled if content verification was in ENFORCE mode.
std::set<std::string> would_be_disabled_ids_;

Powered by Google App Engine
This is Rietveld 408576698