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

Unified Diff: content/browser/service_worker/service_worker_register_job.cc

Issue 1381153004: Service Worker: Change the criteria for bumping the last update check time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change the condition to check if SWRegistration is stored Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
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 69f5acdcb9c995aaa4c2b258356001fe1f6fb181..d5fa1949fd5d7704949801bd9f075fed7de17819 100644
--- a/content/browser/service_worker/service_worker_register_job.cc
+++ b/content/browser/service_worker/service_worker_register_job.cc
@@ -352,6 +352,19 @@ 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. We assume that the
+ // BYPASS_CACHE flag evicts an existing cache entry, so even if the install
+ // ultimately failed for whatever reason, we know the version in the HTTP
+ // cache is not stale, so it's OK to bump the update check time.
+ if (new_version()->embedded_worker()->network_accessed_for_script() ||
+ new_version()->force_bypass_cache_for_scripts()) {
+ registration()->set_last_update_check(base::Time::Now());
+
+ if (registration()->waiting_version() || registration()->active_version())
michaeln 2016/01/19 19:20:28 if job_type_ == UPDATE_JOB works as the condition
jungkees 2016/01/20 05:38:11 I discussed with falken@ and tried so, but later h
falken 2016/01/20 09:31:54 Right. I was then worried about whether waiting_ve
+ context_->storage()->UpdateLastUpdateCheckTime(registration());
+ }
michaeln 2016/01/21 20:55:31 else { there's an assumption here that last_update
jungkees 2016/01/22 05:22:27 Done.
+
if (status == SERVICE_WORKER_OK) {
InstallAndContinue();
return;
@@ -359,16 +372,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;
@@ -433,7 +436,6 @@ void ServiceWorkerRegisterJob::OnInstallFinished(
}
SetPhase(STORE);
- registration()->set_last_update_check(base::Time::Now());
michaeln 2016/01/19 19:20:28 Is there any chance we can be here w/o having set
jungkees 2016/01/20 05:38:11 No, I don't think so.
falken 2016/01/20 09:31:54 I guess it'd only be possible if network_accessed_
michaeln 2016/01/21 20:55:31 Right, an assurance of some kind about having a me
jungkees 2016/01/22 05:22:26 Okay. To assure that, I added this assertion as we
context_->storage()->StoreRegistration(
registration(),
new_version(),

Powered by Google App Engine
This is Rietveld 408576698