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

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

Issue 457903002: After 24 hours, bust the browser cache when checking for ServiceWorker updates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 87e5ebb087e56729c97209876b16a135dc1325b7..f428d4400993bf4c55c32c5077fd0be9b6a7faa2 100644
--- a/content/browser/service_worker/service_worker_register_job.cc
+++ b/content/browser/service_worker/service_worker_register_job.cc
@@ -231,6 +231,10 @@ void ServiceWorkerRegisterJob::ContinueWithUpdate(
return;
}
+ // TODO(michaeln): If the last update check was less then 24 hours
dominicc (has gone to gerrit) 2014/08/11 04:01:15 then -> than
michaeln 2014/08/13 03:42:55 Done.
+ // ago, depending on the freshness of the cached worker script we
+ // may be able to complete the update job right here.
+
UpdateAndContinue();
}
@@ -322,6 +326,7 @@ void ServiceWorkerRegisterJob::OnInstallFinished(
}
SetPhase(STORE);
+ registration()->set_last_update_check(base::Time::Now());
context_->storage()->StoreRegistration(
registration(),
new_version(),
@@ -415,11 +420,13 @@ void ServiceWorkerRegisterJob::ResolvePromise(
void ServiceWorkerRegisterJob::OnPausedAfterDownload() {
// This happens prior to OnStartWorkerFinished time.
- scoped_refptr<ServiceWorkerVersion> current_version =
- registration()->active_version();
- DCHECK(current_version);
- int64 current_script_id =
- current_version->script_cache_map()->Lookup(script_url_);
+ scoped_refptr<ServiceWorkerVersion> most_recent_version =
+ registration()->waiting_version() ?
+ registration()->waiting_version() :
+ registration()->active_version();
+ DCHECK(most_recent_version);
+ int64 most_recent_script_id =
+ most_recent_version->script_cache_map()->Lookup(script_url_);
int64 new_script_id =
new_version()->script_cache_map()->Lookup(script_url_);
@@ -427,10 +434,10 @@ void ServiceWorkerRegisterJob::OnPausedAfterDownload() {
// is being downloaded and to avoid writing it to disk until we know
// its needed.
context_->storage()->CompareScriptResources(
- current_script_id, new_script_id,
+ most_recent_script_id, new_script_id,
base::Bind(&ServiceWorkerRegisterJob::OnCompareScriptResourcesComplete,
weak_factory_.GetWeakPtr(),
- current_version));
+ most_recent_version));
}
bool ServiceWorkerRegisterJob::OnMessageReceived(const IPC::Message& message) {
@@ -438,11 +445,13 @@ bool ServiceWorkerRegisterJob::OnMessageReceived(const IPC::Message& message) {
}
void ServiceWorkerRegisterJob::OnCompareScriptResourcesComplete(
- ServiceWorkerVersion* current_version,
+ ServiceWorkerVersion* most_recent_version,
ServiceWorkerStatusCode status,
bool are_equal) {
if (are_equal) {
- ResolvePromise(SERVICE_WORKER_OK, registration(), current_version);
+ ResolvePromise(SERVICE_WORKER_OK, registration(), most_recent_version);
+ registration()->set_last_update_check(base::Time::Now());
+ context_->storage()->UpdateLastUpdateCheckTime(registration());
Complete(SERVICE_WORKER_ERROR_EXISTS);
return;
}

Powered by Google App Engine
This is Rietveld 408576698