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

Side by Side Diff: chrome/browser/extensions/policy_extension_reinstaller.h

Issue 2790823004: Retry reinstallation of corrupted policy extensions. (Closed)
Patch Set: address comments Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_POLICY_EXTENSION_REINSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_POLICY_EXTENSION_REINSTALLER_H_
7
8 #include <memory>
9
10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h"
13 #include "extensions/common/extension_id.h"
14 #include "net/base/backoff_entry.h"
15
16 namespace content {
17 class BrowserContext;
18 }
19
20 namespace extensions {
21
22 // Class that asks ExtensionService to reinstall corrupted policy extensions.
23 // If a reinstallation fails for some reason (e.g. network unavailability) then
24 // it will retry reinstallation with backoff.
25 class PolicyExtensionReinstaller {
26 public:
27 using ReinstallCallback = base::Callback<void(const base::Closure& callback,
28 base::TimeDelta delay)>;
29
30 explicit PolicyExtensionReinstaller(content::BrowserContext* context);
31 ~PolicyExtensionReinstaller();
32
33 // Notifies this reinstaller about a policy extension corruption.
34 void NotifyExtensionDisabledDueToCorruption();
35
36 // For tests, overrides the default action to take to initiate policy
37 // force-reinstalls.
38 static void set_policy_reinstall_action_for_test(ReinstallCallback* action);
39
40 private:
41 void Fire();
42 base::TimeDelta GetNextFireDelay();
43 void ScheduleNextReinstallAttempt();
44
45 content::BrowserContext* const context_ = nullptr;
46 net::BackoffEntry backoff_entry_;
47 // Whether or not there is a pending PostTask to Fire().
48 bool scheduled_fire_pending_ = false;
49
50 base::WeakPtrFactory<PolicyExtensionReinstaller> weak_factory_;
51
52 DISALLOW_COPY_AND_ASSIGN(PolicyExtensionReinstaller);
53 };
54
55 } // namespace extensions
56
57 #endif // CHROME_BROWSER_EXTENSIONS_POLICY_EXTENSION_REINSTALLER_H_
OLDNEW
« 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