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

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

Issue 477593007: ServiceWorker: Make '.ready' return a promise to be resolved with ServiceWorkerRegistration (2/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 3 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_provider_host.cc
diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc
index 4cc054a7f021f2b7d42d0c12ac323b71a61fd55a..7d887c5a3458e70397968142ef2b2d93a6e246d2 100644
--- a/content/browser/service_worker/service_worker_provider_host.cc
+++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -60,7 +60,7 @@ void ServiceWorkerProviderHost::OnVersionAttributesChanged(
void ServiceWorkerProviderHost::OnRegistrationFailed(
ServiceWorkerRegistration* registration) {
DCHECK_EQ(associated_registration_.get(), registration);
- UnassociateRegistration();
+ DisassociateRegistration();
}
void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) {
@@ -116,15 +116,32 @@ void ServiceWorkerProviderHost::AssociateRegistration(
DecreaseProcessReference(associated_registration_->pattern());
IncreaseProcessReference(registration->pattern());
+ if (dispatcher_host_) {
+ ServiceWorkerRegistrationHandle* handle =
+ dispatcher_host_->GetOrCreateRegistrationHandle(
+ provider_id(), registration);
+
+ ServiceWorkerVersionAttributes attrs;
+ attrs.installing = handle->CreateServiceWorkerHandleAndPass(
+ registration->installing_version());
+ attrs.waiting = handle->CreateServiceWorkerHandleAndPass(
+ registration->waiting_version());
+ attrs.active = handle->CreateServiceWorkerHandleAndPass(
+ registration->active_version());
+
+ dispatcher_host_->Send(new ServiceWorkerMsg_AssociateRegistration(
+ kDocumentMainThreadId, provider_id(), handle->GetObjectInfo(), attrs));
+ }
+
associated_registration_ = registration;
- registration->AddListener(this);
+ associated_registration_->AddListener(this);
installing_version_ = registration->installing_version();
waiting_version_ = registration->waiting_version();
active_version_ = registration->active_version();
SetControllerVersionAttribute(registration->active_version());
}
-void ServiceWorkerProviderHost::UnassociateRegistration() {
+void ServiceWorkerProviderHost::DisassociateRegistration() {
if (!associated_registration_.get())
return;
DecreaseProcessReference(associated_registration_->pattern());
@@ -134,6 +151,11 @@ void ServiceWorkerProviderHost::UnassociateRegistration() {
waiting_version_ = NULL;
active_version_ = NULL;
SetControllerVersionAttribute(NULL);
+
+ if (dispatcher_host_) {
+ dispatcher_host_->Send(new ServiceWorkerMsg_DisassociateRegistration(
+ kDocumentMainThreadId, provider_id()));
+ }
}
scoped_ptr<ServiceWorkerRequestHandler>

Powered by Google App Engine
This is Rietveld 408576698