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

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

Issue 849163002: ServiceWorker: Expose registration within ServiceWorkerGlobalScope [2/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove dcheck 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/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 0a30cfbb25c612454d851c7cfcfe20f34762a9f7..f33b86a0c8b0988c1aa209eaa24b37aafec8eec0 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -57,6 +57,8 @@ ServiceWorkerDispatcher::~ServiceWorkerDispatcher() {
void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ServiceWorkerDispatcher, msg)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_AssociateRegistrationWithServiceWorker,
+ OnAssociateRegistrationWithServiceWorker)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_AssociateRegistration,
OnAssociateRegistration)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DisassociateRegistration,
@@ -300,6 +302,27 @@ ServiceWorkerDispatcher::CreateServiceWorkerRegistration(
return new WebServiceWorkerRegistrationImpl(handle_ref.Pass());
}
+// We can assume that this message handler is called before the worker context
+// starts because script loading happens after this association.
+// TODO(nhiroki): This association information could be pushed into
+// EmbeddedWorkerMsg_StartWorker message and handed over to the worker thread
+// without a lock in ServiceWorkerProviderContext.
+void ServiceWorkerDispatcher::OnAssociateRegistrationWithServiceWorker(
+ int thread_id,
+ int provider_id,
+ const ServiceWorkerRegistrationObjectInfo& info,
+ const ServiceWorkerVersionAttributes& attrs) {
+ DCHECK_EQ(kDocumentMainThreadId, thread_id);
+
+ ProviderContextMap::iterator context = provider_contexts_.find(provider_id);
+ if (context == provider_contexts_.end())
+ return;
+ context->second->OnAssociateRegistration(info, attrs);
+
+ // We don't have to add entries into |worker_to_provider_| because state
+ // change events for the workers will be notified on the worker thread.
+}
+
void ServiceWorkerDispatcher::OnAssociateRegistration(
int thread_id,
int provider_id,

Powered by Google App Engine
This is Rietveld 408576698