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

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

Issue 369013002: ServiceWorker: Support navigator.serviceWorker.installing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 9bd8ba906719302257e5804dd31792e27513b949..bc0ef00891d0a4a6e202aa435e3d35bb4c775313 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -58,6 +58,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnRegistrationError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged,
OnServiceWorkerStateChanged)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetInstallingServiceWorker,
+ OnSetInstallingServiceWorker)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetWaitingServiceWorker,
OnSetWaitingServiceWorker)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetControllerServiceWorker,
@@ -128,6 +130,7 @@ void ServiceWorkerDispatcher::RemoveProviderContext(
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->controller_handle_id());
}
@@ -256,6 +259,33 @@ void ServiceWorkerDispatcher::OnServiceWorkerStateChanged(
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,

Powered by Google App Engine
This is Rietveld 408576698