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

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

Issue 1903043005: service worker: Bump update time even when the script was identical (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix asan Created 4 years, 8 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
« no previous file with comments | « content/browser/service_worker/service_worker_register_job.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 50e8dbd3f4db01c4d24790bb444c6831fe3e5196..8cd8bd53d740028f0d2b409ff71a05f2646d00e4 100644
--- a/content/browser/service_worker/service_worker_register_job.cc
+++ b/content/browser/service_worker/service_worker_register_job.cc
@@ -358,19 +358,7 @@ 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()->last_update_check().is_null()) {
- registration()->set_last_update_check(base::Time::Now());
-
- if (registration()->has_installed_version())
- context_->storage()->UpdateLastUpdateCheckTime(registration());
- }
+ BumpLastUpdateCheckTimeIfNeeded();
if (status == SERVICE_WORKER_OK) {
InstallAndContinue();
@@ -589,6 +577,8 @@ void ServiceWorkerRegisterJob::OnScriptLoaded() {
// a script cache error only in the byte-for-byte identical case.
DCHECK_EQ(status.error(),
ServiceWorkerWriteToCacheJob::kIdenticalScriptError);
+
+ BumpLastUpdateCheckTimeIfNeeded();
ResolvePromise(SERVICE_WORKER_OK, std::string(), registration());
Complete(SERVICE_WORKER_ERROR_EXISTS,
"The updated worker is identical to the incumbent.");
@@ -598,4 +588,20 @@ void ServiceWorkerRegisterJob::OnScriptLoaded() {
new_version()->embedded_worker()->ResumeAfterDownload();
}
+void ServiceWorkerRegisterJob::BumpLastUpdateCheckTimeIfNeeded() {
+ // 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()->last_update_check().is_null()) {
+ registration()->set_last_update_check(base::Time::Now());
+
+ if (registration()->has_installed_version())
+ context_->storage()->UpdateLastUpdateCheckTime(registration());
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/service_worker/service_worker_register_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698