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

Unified Diff: content/browser/service_worker/embedded_worker_registry.cc

Issue 2227593002: ServiceWorker: Implement StartWorker by using mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialized StartParams Created 4 years, 3 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/browser/service_worker/embedded_worker_registry.cc
diff --git a/content/browser/service_worker/embedded_worker_registry.cc b/content/browser/service_worker/embedded_worker_registry.cc
index 51d3c2c5ca2d368f5c1dbb27e3277fdad58fe1cf..e63bb732e46fe85c7dfbc23ee70c3a8a004429a2 100644
--- a/content/browser/service_worker/embedded_worker_registry.cc
+++ b/content/browser/service_worker/embedded_worker_registry.cc
@@ -245,7 +245,7 @@ EmbeddedWorkerRegistry::~EmbeddedWorkerRegistry() {
}
ServiceWorkerStatusCode EmbeddedWorkerRegistry::SendStartWorker(
- std::unique_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
+ std::unique_ptr<EmbeddedWorkerStartParams> params,
int process_id) {
if (!context_)
return SERVICE_WORKER_ERROR_ABORT;
@@ -265,10 +265,30 @@ ServiceWorkerStatusCode EmbeddedWorkerRegistry::SendStartWorker(
ServiceWorkerStatusCode status =
Send(process_id, new EmbeddedWorkerMsg_StartWorker(*params));
if (status == SERVICE_WORKER_OK)
- worker_process_map_[process_id].insert(embedded_worker_id);
+ BindWorkerToProcess(process_id, embedded_worker_id);
return status;
}
+ServiceWorkerStatusCode EmbeddedWorkerRegistry::BindWorkerToProcess(
+ int process_id,
+ int embedded_worker_id) {
+ if (!context_)
+ return SERVICE_WORKER_ERROR_ABORT;
falken 2016/09/13 05:48:02 nit: If I understand correctly this function isn't
shimazu 2016/09/15 03:24:42 I think so. Removed.
+
+ // The ServiceWorkerDispatcherHost is supposed to be created when the process
+ // is created, and keep an entry in process_sender_map_ for its whole
+ // lifetime.
+ DCHECK(base::ContainsKey(process_sender_map_, process_id));
+ DCHECK(GetWorker(embedded_worker_id));
+ DCHECK_EQ(GetWorker(embedded_worker_id)->process_id(), process_id);
+ DCHECK(
+ !base::ContainsKey(worker_process_map_, process_id) ||
+ !base::ContainsKey(worker_process_map_[process_id], embedded_worker_id));
+
+ worker_process_map_[process_id].insert(embedded_worker_id);
+ return SERVICE_WORKER_OK;
+}
+
ServiceWorkerStatusCode EmbeddedWorkerRegistry::Send(
int process_id, IPC::Message* message_ptr) {
std::unique_ptr<IPC::Message> message(message_ptr);

Powered by Google App Engine
This is Rietveld 408576698