| Index: chrome/browser/extensions/chrome_content_verifier_delegate.cc
|
| diff --git a/chrome/browser/extensions/chrome_content_verifier_delegate.cc b/chrome/browser/extensions/chrome_content_verifier_delegate.cc
|
| index d6ea2c6af5de5f0ca117ef299d4580447feb2da4..ac337c4c4ee869fbf38808cc16c0913d3a3e297a 100644
|
| --- a/chrome/browser/extensions/chrome_content_verifier_delegate.cc
|
| +++ b/chrome/browser/extensions/chrome_content_verifier_delegate.cc
|
| @@ -11,10 +11,11 @@
|
|
|
| #include "base/base_switches.h"
|
| #include "base/command_line.h"
|
| -#include "base/syslog_logging.h"
|
| #include "base/metrics/field_trial.h"
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/strings/string_util.h"
|
| +#include "base/syslog_logging.h"
|
| +#include "base/threading/thread_task_runner_handle.h"
|
| #include "base/version.h"
|
| #include "build/build_config.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| @@ -30,6 +31,7 @@
|
| #include "extensions/common/extensions_client.h"
|
| #include "extensions/common/manifest.h"
|
| #include "extensions/common/manifest_url_handlers.h"
|
| +#include "net/base/backoff_entry.h"
|
| #include "net/base/escape.h"
|
|
|
| #if defined(OS_CHROMEOS)
|
| @@ -41,6 +43,33 @@ namespace {
|
| const char kContentVerificationExperimentName[] =
|
| "ExtensionContentVerification";
|
|
|
| +const net::BackoffEntry::Policy kPolicyReinstallBackoffPolicy = {
|
| + // num_errors_to_ignore
|
| + 1,
|
| +
|
| + // initial_delay_ms (note that we set 'always_use_initial_delay' to false
|
| + // below)
|
| + 100,
|
| +
|
| + // multiply_factor
|
| + 2,
|
| +
|
| + // jitter_factor
|
| + 0.1,
|
| +
|
| + // maximum_backoff_ms (30 minutes)
|
| + 1000 * 60 * 30,
|
| +
|
| + // entry_lifetime_ms (6 hours)
|
| + 1000 * 60 * 60 * 6,
|
| +
|
| + // always_use_initial_delay
|
| + false,
|
| +};
|
| +
|
| +base::Callback<void(base::TimeDelta delay)>* g_reinstall_action_for_test =
|
| + nullptr;
|
| +
|
| } // namespace
|
|
|
| namespace extensions {
|
| @@ -186,7 +215,28 @@ void ChromeContentVerifierDelegate::VerifyFailed(
|
| << extension->path().value();
|
| pending_manager->ExpectPolicyReinstallForCorruption(extension_id);
|
| service->DisableExtension(extension_id, Extension::DISABLE_CORRUPTED);
|
| - service->CheckForExternalUpdates();
|
| +
|
| + net::BackoffEntry* backoff_entry = nullptr;
|
| + auto iter = policy_reinstall_backoff_.find(extension_id);
|
| + if (iter != policy_reinstall_backoff_.end()) {
|
| + backoff_entry = iter->second.get();
|
| + } else {
|
| + auto new_backoff_entry =
|
| + base::MakeUnique<net::BackoffEntry>(&kPolicyReinstallBackoffPolicy);
|
| + backoff_entry = new_backoff_entry.get();
|
| + policy_reinstall_backoff_[extension_id] = std::move(new_backoff_entry);
|
| + }
|
| + backoff_entry->InformOfRequest(false);
|
| +
|
| + base::TimeDelta reinstall_delay = backoff_entry->GetTimeUntilRelease();
|
| + if (g_reinstall_action_for_test) {
|
| + g_reinstall_action_for_test->Run(reinstall_delay);
|
| + } else {
|
| + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| + FROM_HERE, base::Bind(&ExtensionService::CheckForExternalUpdates,
|
| + service->AsWeakPtr()),
|
| + reinstall_delay);
|
| + }
|
| return;
|
| }
|
| DLOG(WARNING) << "Disabling extension " << extension_id << " ('"
|
| @@ -205,5 +255,10 @@ void ChromeContentVerifierDelegate::VerifyFailed(
|
| }
|
| }
|
|
|
| +// static
|
| +void ChromeContentVerifierDelegate::set_policy_reinstall_action_for_test(
|
| + base::Callback<void(base::TimeDelta delay)>* action) {
|
| + g_reinstall_action_for_test = action;
|
| +}
|
|
|
| } // namespace extensions
|
|
|