Chromium Code Reviews| 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..b5dbef6ece1c1ac388fd64aa264fec8a2bd7df82 |
| --- /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/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
|
| +#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: |
| + 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( |
| + base::Callback<void(const base::Closure& callback, |
| + base::TimeDelta delay)>* action); |
| + |
| + private: |
| + void Fire(); |
| + base::TimeDelta GetNextFireDelay(); |
| + void ScheduleNextReinstallAttempt(); |
| + |
| + 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
|
| + 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_ |