Merge from Chromium at DEPS revision 284076
This commit was generated by merge_to_master.py.
Change-Id: I9a279485b02fe7ceddcd32d992a714ff132e99ae
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index 936f5c8..81f2c4e 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -58,10 +58,14 @@
OnRegistrationError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged,
OnServiceWorkerStateChanged)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetInstallingServiceWorker,
+ OnSetInstallingServiceWorker)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetWaitingServiceWorker,
OnSetWaitingServiceWorker)
- IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetCurrentServiceWorker,
- OnSetCurrentServiceWorker)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetActiveServiceWorker,
+ OnSetActiveServiceWorker)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetControllerServiceWorker,
+ OnSetControllerServiceWorker)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToDocument,
OnPostMessage)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -128,8 +132,10 @@
DCHECK(provider_context);
DCHECK(ContainsKey(provider_contexts_, provider_context->provider_id()));
provider_contexts_.erase(provider_context->provider_id());
+ worker_to_provider_.erase(provider_context->installing_handle_id());
worker_to_provider_.erase(provider_context->waiting_handle_id());
- worker_to_provider_.erase(provider_context->current_handle_id());
+ worker_to_provider_.erase(provider_context->active_handle_id());
+ worker_to_provider_.erase(provider_context->controller_handle_id());
}
void ServiceWorkerDispatcher::AddScriptClient(
@@ -256,6 +262,33 @@
provider->second->OnServiceWorkerStateChanged(handle_id, state);
}
+void ServiceWorkerDispatcher::OnSetInstallingServiceWorker(
+ int thread_id,
+ int provider_id,
+ const ServiceWorkerObjectInfo& info) {
+ ProviderContextMap::iterator provider = provider_contexts_.find(provider_id);
+ if (provider != provider_contexts_.end()) {
+ int existing_installing_id = provider->second->installing_handle_id();
+ if (existing_installing_id != info.handle_id &&
+ existing_installing_id != kInvalidServiceWorkerHandleId) {
+ WorkerToProviderMap::iterator associated_provider =
+ worker_to_provider_.find(existing_installing_id);
+ DCHECK(associated_provider != worker_to_provider_.end());
+ DCHECK(associated_provider->second->provider_id() == provider_id);
+ worker_to_provider_.erase(associated_provider);
+ }
+ provider->second->OnSetInstallingServiceWorker(provider_id, info);
+ if (info.handle_id != kInvalidServiceWorkerHandleId)
+ worker_to_provider_[info.handle_id] = provider->second;
+ }
+
+ ScriptClientMap::iterator found = script_clients_.find(provider_id);
+ if (found != script_clients_.end()) {
+ // Populate the .installing field with the new worker object.
+ found->second->setInstalling(GetServiceWorker(info, false));
+ }
+}
+
void ServiceWorkerDispatcher::OnSetWaitingServiceWorker(
int thread_id,
int provider_id,
@@ -283,13 +316,40 @@
}
}
-void ServiceWorkerDispatcher::OnSetCurrentServiceWorker(
+void ServiceWorkerDispatcher::OnSetActiveServiceWorker(
int thread_id,
int provider_id,
const ServiceWorkerObjectInfo& info) {
ProviderContextMap::iterator provider = provider_contexts_.find(provider_id);
if (provider != provider_contexts_.end()) {
- provider->second->OnSetCurrentServiceWorker(provider_id, info);
+ int existing_active_id = provider->second->active_handle_id();
+ if (existing_active_id != info.handle_id &&
+ existing_active_id != kInvalidServiceWorkerHandleId) {
+ WorkerToProviderMap::iterator associated_provider =
+ worker_to_provider_.find(existing_active_id);
+ DCHECK(associated_provider != worker_to_provider_.end());
+ DCHECK(associated_provider->second->provider_id() == provider_id);
+ worker_to_provider_.erase(associated_provider);
+ }
+ provider->second->OnSetActiveServiceWorker(provider_id, info);
+ if (info.handle_id != kInvalidServiceWorkerHandleId)
+ worker_to_provider_[info.handle_id] = provider->second;
+ }
+
+ ScriptClientMap::iterator found = script_clients_.find(provider_id);
+ if (found != script_clients_.end()) {
+ // Populate the .active field with the new worker object.
+ found->second->setActive(GetServiceWorker(info, false));
+ }
+}
+
+void ServiceWorkerDispatcher::OnSetControllerServiceWorker(
+ int thread_id,
+ int provider_id,
+ const ServiceWorkerObjectInfo& info) {
+ ProviderContextMap::iterator provider = provider_contexts_.find(provider_id);
+ if (provider != provider_contexts_.end()) {
+ provider->second->OnSetControllerServiceWorker(provider_id, info);
worker_to_provider_[info.handle_id] = provider->second;
}