Index: content/browser/service_worker/service_worker_register_job.cc |
diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc |
index 0a28dc1ccab0af6b23f99e53b9b04f4f851599e6..6c4f7d0b95277e96dc54023def42bd7f55d4f25d 100644 |
--- a/content/browser/service_worker/service_worker_register_job.cc |
+++ b/content/browser/service_worker/service_worker_register_job.cc |
@@ -81,6 +81,17 @@ void ServiceWorkerRegisterJob::AddCallback( |
void ServiceWorkerRegisterJob::Start() { |
SetPhase(START); |
+ |
+ if (IsBrowserStartingUp()) { |
+ // Delay running update jobs until after startup. |
+ const base::TimeDelta kRetryInterval = base::TimeDelta::FromSeconds(15); |
+ delayed_start_timer_.Start( |
+ FROM_HERE, kRetryInterval, |
+ base::Bind(&ServiceWorkerRegisterJob::Restart, |
+ weak_factory_.GetWeakPtr())); |
+ return; |
+ } |
+ |
ServiceWorkerStorage::FindRegistrationCallback next_step; |
if (job_type_ == REGISTRATION_JOB) { |
next_step = base::Bind( |
@@ -183,6 +194,12 @@ void ServiceWorkerRegisterJob::SetPhase(Phase phase) { |
phase_ = phase; |
} |
+void ServiceWorkerRegisterJob::Restart() { |
+ DCHECK(phase_ == START) << phase_; |
+ phase_ = INITIAL; |
+ Start(); |
+} |
+ |
// This function corresponds to the steps in [[Register]] following |
// "Let registration be the result of running the [[GetRegistration]] algorithm. |
// Throughout this file, comments in quotes are excerpts from the spec. |