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

Unified Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 517493002: ServiceWorker: Update the install sequence as per the latest spec (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/child/service_worker/service_worker_dispatcher.cc
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index 74ec956efc857173f7ee24cf789b0fe598de44e5..2cc80509590d3f01ad95f34ce70458df44f510df 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -62,6 +62,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnServiceWorkerStateChanged)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes,
OnSetVersionAttributes)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_UpdateFound,
+ OnUpdateFound)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetControllerServiceWorker,
OnSetControllerServiceWorker)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToDocument,
@@ -238,14 +240,26 @@ ServiceWorkerDispatcher::GetServiceWorkerRegistration(
void ServiceWorkerDispatcher::OnRegistered(
int thread_id,
int request_id,
- const ServiceWorkerRegistrationObjectInfo& info) {
+ const ServiceWorkerRegistrationObjectInfo& info,
+ const ServiceWorkerVersionAttributes& attrs) {
WebServiceWorkerRegistrationCallbacks* callbacks =
pending_callbacks_.Lookup(request_id);
DCHECK(callbacks);
if (!callbacks)
return;
- callbacks->onSuccess(GetServiceWorkerRegistration(info, true));
+ WebServiceWorkerRegistrationImpl* registration =
+ GetServiceWorkerRegistration(info, true);
+
+ ChangedVersionAttributesMask mask(attrs.changed_mask);
+ if (mask.installing_changed())
+ registration->SetInstalling(GetServiceWorker(attrs.installing, true));
+ if (mask.waiting_changed())
+ registration->SetWaiting(GetServiceWorker(attrs.waiting, true));
+ if (mask.active_changed())
+ registration->SetActive(GetServiceWorker(attrs.active, true));
+
+ callbacks->onSuccess(registration);
pending_callbacks_.Remove(request_id);
}
@@ -296,26 +310,33 @@ void ServiceWorkerDispatcher::OnSetVersionAttributes(
int thread_id,
int provider_id,
int registration_handle_id,
- int changed_mask,
- const ServiceWorkerVersionAttributes& attributes) {
- ChangedVersionAttributesMask mask(changed_mask);
+ const ServiceWorkerVersionAttributes& attrs) {
+ ChangedVersionAttributesMask mask(attrs.changed_mask);
if (mask.installing_changed()) {
SetInstallingServiceWorker(provider_id,
registration_handle_id,
- attributes.installing);
+ attrs.installing);
}
if (mask.waiting_changed()) {
SetWaitingServiceWorker(provider_id,
registration_handle_id,
- attributes.waiting);
+ attrs.waiting);
}
if (mask.active_changed()) {
SetActiveServiceWorker(provider_id,
registration_handle_id,
- attributes.active);
+ attrs.active);
}
}
+void ServiceWorkerDispatcher::OnUpdateFound(
+ int thread_id,
+ const ServiceWorkerRegistrationObjectInfo& info) {
+ RegistrationObjectMap::iterator found = registrations_.find(info.handle_id);
+ if (found != registrations_.end())
+ found->second->OnUpdateFound();
+}
+
void ServiceWorkerDispatcher::SetInstallingServiceWorker(
int provider_id,
int registration_handle_id,
@@ -341,8 +362,6 @@ void ServiceWorkerDispatcher::SetInstallingServiceWorker(
if (found != registrations_.end()) {
// Populate the .installing field with the new worker object.
found->second->SetInstalling(GetServiceWorker(info, false));
- if (info.handle_id != kInvalidServiceWorkerHandleId)
- found->second->OnUpdateFound();
}
}

Powered by Google App Engine
This is Rietveld 408576698