Chromium Code Reviews| 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 244905ef69c213e2d69d80e35acbdb899aa413a2..12f18b79fca8125fe2a90a4511e21d07e2fbf2c1 100644 |
| --- a/content/browser/service_worker/service_worker_register_job.cc |
| +++ b/content/browser/service_worker/service_worker_register_job.cc |
| @@ -350,6 +350,17 @@ void ServiceWorkerRegisterJob::UpdateAndContinue() { |
| void ServiceWorkerRegisterJob::OnStartWorkerFinished( |
| ServiceWorkerStatusCode status) { |
| + // Bump the last update check time only when the register/update job fetched |
| + // the version having bypassed the network cache. |
|
falken
2015/12/07 07:40:33
Please add a comment here about the side effect of
jungkees
2015/12/15 13:07:45
Done.
|
| + if (new_version()->embedded_worker()->network_accessed_for_script() || |
| + new_version()->force_bypass_cache_for_scripts()) { |
| + registration()->set_last_update_check(base::Time::Now()); |
| + |
| + // Avoid reading disk for first time registrations. |
|
falken
2015/12/07 07:40:33
I think you can just remove this comment. It's cle
jungkees
2015/12/15 13:07:45
Done.
|
| + if (job_type_ == UPDATE_JOB) |
| + context_->storage()->UpdateLastUpdateCheckTime(registration()); |
| + } |
| + |
| if (status == SERVICE_WORKER_OK) { |
| InstallAndContinue(); |
| return; |
| @@ -357,16 +368,6 @@ void ServiceWorkerRegisterJob::OnStartWorkerFinished( |
| // The updated worker is identical to the incumbent. |
| if (status == SERVICE_WORKER_ERROR_EXISTS) { |
| - // Only bump the last check time when we've bypassed the browser cache. |
| - base::TimeDelta time_since_last_check = |
| - base::Time::Now() - registration()->last_update_check(); |
| - if (time_since_last_check > base::TimeDelta::FromHours( |
| - kServiceWorkerScriptMaxCacheAgeInHours) || |
| - new_version()->force_bypass_cache_for_scripts()) { |
| - registration()->set_last_update_check(base::Time::Now()); |
| - context_->storage()->UpdateLastUpdateCheckTime(registration()); |
| - } |
| - |
| ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); |
| Complete(status, "The updated worker is identical to the incumbent."); |
| return; |
| @@ -431,7 +432,6 @@ void ServiceWorkerRegisterJob::OnInstallFinished( |
| } |
| SetPhase(STORE); |
| - registration()->set_last_update_check(base::Time::Now()); |
| context_->storage()->StoreRegistration( |
| registration(), |
| new_version(), |