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

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

Issue 871853002: ServiceWorker: add ServiceWorkerClients.claim() support (2/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change error type Created 5 years, 11 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 6153b93a747902920cd1602d5151efd0853a289b..63e403a2847d3eb2e9bc5377e33b9d4823ac3061 100644
--- a/content/browser/service_worker/service_worker_provider_host.cc
+++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -89,7 +89,7 @@ void ServiceWorkerProviderHost::OnSkippedWaiting(
return;
ServiceWorkerVersion* active_version = registration->active_version();
DCHECK_EQ(active_version->status(), ServiceWorkerVersion::ACTIVATING);
- SetControllerVersionAttribute(active_version);
+ SetControllerVersionAttribute(active_version, true);
falken 2015/01/26 08:45:13 nit: can you add /* should_notify_controller_chang
xiang 2015/01/28 05:38:35 Done.
}
void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) {
@@ -102,7 +102,8 @@ void ServiceWorkerProviderHost::SetTopmostFrameUrl(const GURL& url) {
}
void ServiceWorkerProviderHost::SetControllerVersionAttribute(
- ServiceWorkerVersion* version) {
+ ServiceWorkerVersion* version,
+ bool should_notify_controllerchange) {
if (version == controlling_version_.get())
return;
@@ -116,9 +117,6 @@ void ServiceWorkerProviderHost::SetControllerVersionAttribute(
if (!dispatcher_host_)
return; // Could be NULL in some tests.
- bool should_notify_controllerchange =
- previous_version && version && version->skip_waiting();
-
dispatcher_host_->Send(new ServiceWorkerMsg_SetControllerServiceWorker(
kDocumentMainThreadId, provider_id(),
dispatcher_host_->CreateAndRegisterServiceWorkerHandle(version),
@@ -148,16 +146,16 @@ bool ServiceWorkerProviderHost::SetHostedVersionId(int64 version_id) {
}
void ServiceWorkerProviderHost::AssociateRegistration(
- ServiceWorkerRegistration* registration) {
+ ServiceWorkerRegistration* registration,
+ bool should_notify_controllerchange) {
DCHECK(CanAssociateRegistration(registration));
- if (associated_registration_.get())
- DecreaseProcessReference(associated_registration_->pattern());
IncreaseProcessReference(registration->pattern());
associated_registration_ = registration;
associated_registration_->AddListener(this);
SendAssociateRegistrationMessage();
- SetControllerVersionAttribute(registration->active_version());
+ SetControllerVersionAttribute(registration->active_version(),
+ should_notify_controllerchange);
}
void ServiceWorkerProviderHost::DisassociateRegistration() {
@@ -166,7 +164,7 @@ void ServiceWorkerProviderHost::DisassociateRegistration() {
DecreaseProcessReference(associated_registration_->pattern());
associated_registration_->RemoveListener(this);
associated_registration_ = NULL;
- SetControllerVersionAttribute(NULL);
+ SetControllerVersionAttribute(NULL, false);
if (dispatcher_host_) {
dispatcher_host_->Send(new ServiceWorkerMsg_DisassociateRegistration(
@@ -250,6 +248,17 @@ void ServiceWorkerProviderHost::GetClientInfo(
kDocumentMainThreadId, embedded_worker_id, request_id, provider_id()));
}
+void ServiceWorkerProviderHost::SetController(
+ ServiceWorkerRegistration* registration) {
+ DCHECK(registration->active_version());
+ if (associated_registration_ == registration) {
falken 2015/01/26 08:45:12 when does this happen? if this provider host is as
xiang 2015/01/28 05:38:35 This could happen when a registration associated t
falken 2015/01/28 08:59:49 I see, I was confused and thought SWProviderHost l
+ SetControllerVersionAttribute(registration->active_version(), true);
+ return;
+ }
+ DisassociateRegistration();
+ AssociateRegistration(registration, true);
falken 2015/01/26 08:45:12 /* should_notify_controller_change */
xiang 2015/01/28 05:38:35 Done. We don't need the flags now.
+}
+
void ServiceWorkerProviderHost::AddScopedProcessReferenceToPattern(
const GURL& pattern) {
associated_patterns_.push_back(pattern);

Powered by Google App Engine
This is Rietveld 408576698