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

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

Issue 224733014: Introduce ServiceWorkerHandle for tracking WebServiceWorkerImpl reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sigh, rebased Created 6 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 9ed601b4964ca019aa8a64a96b2555c15346e725..0d60f65c9ba9b7d77e077209589b51a6b5790a3b 100644
--- a/content/browser/service_worker/service_worker_register_job.cc
+++ b/content/browser/service_worker/service_worker_register_job.cc
@@ -85,7 +85,7 @@ void ServiceWorkerRegisterJob::HandleExistingRegistrationAndContinue(
UpdateAndContinue(status);
return;
}
- RunCallbacks(status, registration_->active_version());
+ RunCallbacks(status, registration_, registration_->active_version());
Complete(SERVICE_WORKER_OK);
return;
}
@@ -101,7 +101,6 @@ void ServiceWorkerRegisterJob::HandleExistingRegistrationAndContinue(
// registering a new one.
// TODO(falken): Match the spec. We now throw away the active_version_ and
// pending_version_ of the existing registration, which isn't in the spec.
- registration->Shutdown();
context_->storage()->DeleteRegistration(
pattern_,
base::Bind(&ServiceWorkerRegisterJob::RegisterAndContinue,
@@ -174,7 +173,7 @@ void ServiceWorkerRegisterJob::OnStartWorkerFinished(
// to the callbacks, so pendingWorker must be set first.
DCHECK(!registration_->pending_version());
registration_->set_pending_version(pending_version_);
- RunCallbacks(status, pending_version_.get());
+ RunCallbacks(status, registration_, pending_version_.get());
InstallAndContinue();
}
@@ -222,28 +221,19 @@ void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) {
// (so this is no-op), otherwise we must have come here for abort case,
// so dispatch callbacks with NULL.
DCHECK(callbacks_.empty() || status != SERVICE_WORKER_OK);
- RunCallbacks(status, NULL);
-
- // If |pending_version_| exists, it was not activated, so we are the sole
- // owner of it, so it will be destroyed when this job ends, so Shutdown here.
- // We should be able to remove this code later, when something else holds a
- // reference to |pending_version_|.
- // TODO(kinuko): Fix these ownership and shutdown semantics.
- if (pending_version_) {
- DCHECK(!registration_->pending_version());
- DCHECK(!registration_->active_version());
- pending_version_->Shutdown();
- }
+ RunCallbacks(status, NULL, NULL);
context_->job_coordinator()->FinishJob(pattern_, this);
}
-void ServiceWorkerRegisterJob::RunCallbacks(ServiceWorkerStatusCode status,
- ServiceWorkerVersion* version) {
+void ServiceWorkerRegisterJob::RunCallbacks(
+ ServiceWorkerStatusCode status,
+ ServiceWorkerRegistration* registration,
+ ServiceWorkerVersion* version) {
for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin();
it != callbacks_.end();
++it) {
- it->Run(status, version);
+ it->Run(status, registration, version);
}
callbacks_.clear();
}

Powered by Google App Engine
This is Rietveld 408576698