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

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: fetch registrations from DB 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..39828591505001e8823b10dac4e7fe26b8139dd8 100644
--- a/content/browser/service_worker/service_worker_provider_host.cc
+++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -54,7 +54,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_);
}
@@ -92,6 +93,20 @@ void ServiceWorkerProviderHost::OnSkippedWaiting(
SetControllerVersionAttribute(active_version);
}
+void ServiceWorkerProviderHost::ClaimedByRegistration(
+ ServiceWorkerRegistration* registration) {
+ DCHECK(registration->active_version());
+ is_claiming_ = true;
xiang 2015/01/30 07:18:57 A flag is needed here because AssociateRegistratio
+ if (registration == associated_registration_) {
+ SetControllerVersionAttribute(registration->active_version());
+ } else {
+ DisassociateRegistration();
falken 2015/01/30 10:24:02 As mentioned before, it looks wrong to Disassociat
michaeln 2015/01/30 23:43:07 +1 if (allow_registration_) prior to calling Disas
xiang 2015/02/02 04:24:58 Done.
+ if (CanAssociateRegistration(registration))
+ AssociateRegistration(registration);
+ }
+ is_claiming_ = false;
+}
+
void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) {
DCHECK(!url.has_ref());
document_url_ = url;
@@ -117,7 +132,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());
dispatcher_host_->Send(new ServiceWorkerMsg_SetControllerServiceWorker(
kDocumentMainThreadId, provider_id(),
@@ -150,10 +165,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();

Powered by Google App Engine
This is Rietveld 408576698