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

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

Issue 2790823004: Retry reinstallation of corrupted policy extensions. (Closed)
Patch Set: fix compile 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/gtest_prod_util.h"
Devlin 2017/04/01 03:00:53 needed?
lazyboy 2017/04/03 18:13:04 Ah, was using FRIEND_*, not needed anymore, thanks
12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
14 #include "extensions/common/extension_id.h"
15 #include "net/base/backoff_entry.h"
16
17 namespace content {
18 class BrowserContext;
19 }
20
21 namespace extensions {
22
23 // Class that asks ExtensionService to reinstall corrupted policy extensions.
24 // If a reinstallation fails for some reason (e.g. network unavailability) then
25 // it will retry reinstallation with backoff.
26 class PolicyExtensionReinstaller {
27 public:
28 explicit PolicyExtensionReinstaller(content::BrowserContext* context);
29 ~PolicyExtensionReinstaller();
30
31 // Notifies this reinstaller about a policy extension corruption.
32 void NotifyExtensionDisabledDueToCorruption();
33
34 // For tests, overrides the default action to take to initiate policy
35 // force-reinstalls.
36 static void set_policy_reinstall_action_for_test(
37 base::Callback<void(const base::Closure& callback,
38 base::TimeDelta delay)>* action);
39
40 private:
41 void Fire();
42 base::TimeDelta GetNextFireDelay();
43 void ScheduleNextReinstallAttempt();
44
45 content::BrowserContext* context_;
Devlin 2017/04/01 03:00:53 nit: init to nullptr
lazyboy 2017/04/03 18:13:04 Done. Though this is always initialized in ctor in
Devlin 2017/04/03 21:12:42 Ack, but it's really easy to change a ctor and not
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

Powered by Google App Engine
This is Rietveld 408576698