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

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: remove assignment within conditional expression 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 c5f9b16ef4a6d94b5beac935992e2af8a2e0875f..46f9074cafe25d8536732d9770611fbfcb12c6b7 100644
--- a/content/browser/service_worker/service_worker_provider_host.cc
+++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -57,7 +57,8 @@ ServiceWorkerProviderHost::ServiceWorkerProviderHost(
provider_id_(provider_id),
context_(context),
dispatcher_host_(dispatcher_host),
- allow_association_(true) {
+ allow_association_(true),
+ is_claiming_(false) {
DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_);
if (render_frame_id == MSG_ROUTING_NONE) {
// Actual thread id is set when the worker context gets started.
@@ -124,7 +125,7 @@ void ServiceWorkerProviderHost::SetControllerVersionAttribute(
return; // Could be NULL in some tests.
bool should_notify_controllerchange =
- previous_version && version && version->skip_waiting();
+ is_claiming_ || (previous_version && version && version->skip_waiting());
// SetController message should be sent only for the document context.
DCHECK_EQ(kDocumentMainThreadId, render_thread_id_);
@@ -159,10 +160,7 @@ bool ServiceWorkerProviderHost::SetHostedVersionId(int64 version_id) {
void ServiceWorkerProviderHost::AssociateRegistration(
ServiceWorkerRegistration* registration) {
DCHECK(CanAssociateRegistration(registration));
- if (associated_registration_.get())
- DecreaseProcessReference(associated_registration_->pattern());
IncreaseProcessReference(registration->pattern());
-
associated_registration_ = registration;
associated_registration_->AddListener(this);
SendAssociateRegistrationMessage();
@@ -282,6 +280,19 @@ void ServiceWorkerProviderHost::AddScopedProcessReferenceToPattern(
IncreaseProcessReference(pattern);
}
+void ServiceWorkerProviderHost::ClaimedByRegistration(
+ ServiceWorkerRegistration* registration) {
+ DCHECK(registration->active_version());
+ is_claiming_ = true;
+ if (registration == associated_registration_) {
+ SetControllerVersionAttribute(registration->active_version());
+ } else if (allow_association_) {
+ DisassociateRegistration();
+ AssociateRegistration(registration);
+ }
+ is_claiming_ = false;
+}
+
void ServiceWorkerProviderHost::PrepareForCrossSiteTransfer() {
DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_);
DCHECK_NE(MSG_ROUTING_NONE, render_frame_id_);

Powered by Google App Engine
This is Rietveld 408576698