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

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

Issue 2790823004: Retry reinstallation of corrupted policy extensions. (Closed)
Patch Set: address comments Created 3 years, 9 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/policy_extension_reinstaller.h
diff --git a/chrome/browser/extensions/policy_extension_reinstaller.h b/chrome/browser/extensions/policy_extension_reinstaller.h
new file mode 100644
index 0000000000000000000000000000000000000000..8845747563824b0db7520e409255a1559b56af33
--- /dev/null
+++ b/chrome/browser/extensions/policy_extension_reinstaller.h
@@ -0,0 +1,57 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_POLICY_EXTENSION_REINSTALLER_H_
+#define CHROME_BROWSER_EXTENSIONS_POLICY_EXTENSION_REINSTALLER_H_
+
+#include <memory>
+
+#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
+#include "extensions/common/extension_id.h"
+#include "net/base/backoff_entry.h"
+
+namespace content {
+class BrowserContext;
+}
+
+namespace extensions {
+
+// Class that asks ExtensionService to reinstall corrupted policy extensions.
+// If a reinstallation fails for some reason (e.g. network unavailability) then
+// it will retry reinstallation with backoff.
+class PolicyExtensionReinstaller {
+ public:
+ using ReinstallCallback = base::Callback<void(const base::Closure& callback,
+ base::TimeDelta delay)>;
+
+ explicit PolicyExtensionReinstaller(content::BrowserContext* context);
+ ~PolicyExtensionReinstaller();
+
+ // Notifies this reinstaller about a policy extension corruption.
+ void NotifyExtensionDisabledDueToCorruption();
+
+ // For tests, overrides the default action to take to initiate policy
+ // force-reinstalls.
+ static void set_policy_reinstall_action_for_test(ReinstallCallback* action);
+
+ private:
+ void Fire();
+ base::TimeDelta GetNextFireDelay();
+ void ScheduleNextReinstallAttempt();
+
+ content::BrowserContext* const context_ = nullptr;
+ net::BackoffEntry backoff_entry_;
+ // Whether or not there is a pending PostTask to Fire().
+ bool scheduled_fire_pending_ = false;
+
+ base::WeakPtrFactory<PolicyExtensionReinstaller> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PolicyExtensionReinstaller);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_POLICY_EXTENSION_REINSTALLER_H_
« no previous file with comments | « chrome/browser/extensions/pending_extension_manager.cc ('k') | chrome/browser/extensions/policy_extension_reinstaller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698