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 032dfa2921d3ae5f4d6e83c25e0ee6bc49733a5d..85e834a441a241921af737ea8f469383c3b2a70b 100644 |
--- a/content/child/service_worker/service_worker_dispatcher.cc |
+++ b/content/child/service_worker/service_worker_dispatcher.cc |
@@ -53,6 +53,10 @@ ServiceWorkerDispatcher::~ServiceWorkerDispatcher() { |
void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) { |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(ServiceWorkerDispatcher, msg) |
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_AssociateRegistration, |
+ OnAssociateRegistration) |
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_UnassociateRegistration, |
+ OnUnassociateRegistration) |
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistered, OnRegistered) |
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUnregistered, |
OnUnregistered) |
@@ -237,6 +241,23 @@ ServiceWorkerDispatcher::GetServiceWorkerRegistration( |
return new WebServiceWorkerRegistrationImpl(handle_ref.Pass()); |
} |
+void ServiceWorkerDispatcher::OnAssociateRegistration( |
+ int thread_id, |
+ int provider_id, |
+ const ServiceWorkerRegistrationObjectInfo& info) { |
+ ProviderContextMap::iterator provider = provider_contexts_.find(provider_id); |
+ if (provider != provider_contexts_.end()) |
+ provider->second->AssociateRegistration(info); |
+} |
+ |
+void ServiceWorkerDispatcher::OnUnassociateRegistration( |
+ int thread_id, |
+ int provider_id) { |
+ ProviderContextMap::iterator provider = provider_contexts_.find(provider_id); |
+ if (provider != provider_contexts_.end()) |
+ provider->second->UnassociateRegistration(); |
+} |
+ |
void ServiceWorkerDispatcher::OnRegistered( |
int thread_id, |
int request_id, |
@@ -407,6 +428,16 @@ void ServiceWorkerDispatcher::SetActiveServiceWorker( |
provider->second->OnSetActiveServiceWorker(provider_id, info); |
if (info.handle_id != kInvalidServiceWorkerHandleId) |
worker_to_provider_[info.handle_id] = provider->second; |
+ |
+ if (provider->second->registration_handle_id() == registration_handle_id) { |
+ ScriptClientMap::iterator client = script_clients_.find(provider_id); |
+ if (client != script_clients_.end()) { |
+ // Resolve the .ready promise with the new registration object. |
+ ServiceWorkerRegistrationObjectInfo info = |
+ provider->second->registration()->info(); |
+ client->second->setReady(GetServiceWorkerRegistration(info, false)); |
+ } |
+ } |
} |
RegistrationObjectMap::iterator found = |