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

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

Issue 1928443003: service worker: Update job gets the script url when the job starts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments 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
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 8cd8bd53d740028f0d2b409ff71a05f2646d00e4..0bee03b64a437cbb1d7b7cf57ed4f89fc9f481ad 100644
--- a/content/browser/service_worker/service_worker_register_job.cc
+++ b/content/browser/service_worker/service_worker_register_job.cc
@@ -58,7 +58,6 @@ ServiceWorkerRegisterJob::ServiceWorkerRegisterJob(
: context_(context),
job_type_(UPDATE_JOB),
pattern_(registration->pattern()),
- script_url_(registration->GetNewestVersion()->script_url()),
phase_(INITIAL),
doom_installing_worker_(false),
is_promise_resolved_(false),
@@ -126,10 +125,13 @@ void ServiceWorkerRegisterJob::Abort() {
}
bool ServiceWorkerRegisterJob::Equals(ServiceWorkerRegisterJobBase* job) const {
- if (job->GetType() != GetType())
+ if (job->GetType() != job_type_)
return false;
ServiceWorkerRegisterJob* register_job =
static_cast<ServiceWorkerRegisterJob*>(job);
+ if (job_type_ == UPDATE_JOB)
+ return register_job->pattern_ == pattern_;
+ DCHECK_EQ(REGISTRATION_JOB, job_type_);
return register_job->pattern_ == pattern_ &&
register_job->script_url_ == script_url_;
}
@@ -257,14 +259,16 @@ void ServiceWorkerRegisterJob::ContinueWithUpdate(
return;
}
- // A previous job may have unregistered or installed a new version to this
- // registration.
+ // A previous job may have unregistered this registration.
if (registration()->is_uninstalling() ||
- registration()->GetNewestVersion()->script_url() != script_url_) {
+ !registration()->GetNewestVersion()) {
Complete(SERVICE_WORKER_ERROR_NOT_FOUND);
return;
}
+ DCHECK(script_url_.is_empty());
+ script_url_ = registration()->GetNewestVersion()->script_url();
+
// TODO(michaeln): If the last update check was less than 24 hours
// ago, depending on the freshness of the cached worker script we
// may be able to complete the update job right here.
« no previous file with comments | « content/browser/service_worker/service_worker_register_job.h ('k') | content/browser/service_worker/service_worker_version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698