Chromium Code Reviews| 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 a859268c396b222b3eec789382d84b4ba1c48f5f..35661cbad5d75d35fb98055f2c68f1f61f8a2f3b 100644 |
| --- a/content/browser/service_worker/embedded_worker_registry.cc |
| +++ b/content/browser/service_worker/embedded_worker_registry.cc |
| @@ -11,7 +11,9 @@ |
| #include "content/browser/service_worker/service_worker_context_core.h" |
| #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| #include "content/common/service_worker/embedded_worker_messages.h" |
| +#include "content/common/service_worker/service_worker_messages.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/render_process_host.h" |
| #include "ipc/ipc_message.h" |
| #include "ipc/ipc_sender.h" |
| @@ -23,8 +25,8 @@ EmbeddedWorkerRegistry::EmbeddedWorkerRegistry( |
| next_embedded_worker_id_(0) {} |
| scoped_ptr<EmbeddedWorkerInstance> EmbeddedWorkerRegistry::CreateWorker() { |
| - scoped_ptr<EmbeddedWorkerInstance> worker( |
| - new EmbeddedWorkerInstance(this, next_embedded_worker_id_)); |
| + scoped_ptr<EmbeddedWorkerInstance> worker(new EmbeddedWorkerInstance( |
| + this, next_embedded_worker_id_, context_->storage_partition_path())); |
| worker_map_[next_embedded_worker_id_++] = worker.get(); |
| return worker.Pass(); |
| } |
| @@ -46,12 +48,12 @@ void EmbeddedWorkerRegistry::StartWorker(const std::vector<int>& process_ids, |
| params->scope = scope; |
| params->script_url = script_url; |
| params->worker_devtools_agent_route_id = MSG_ROUTING_NONE; |
| + params->pause_on_start = false; |
| context_->process_manager()->AllocateWorkerProcess( |
| process_ids, |
| script_url, |
| - base::Bind(&EmbeddedWorkerRegistry::StartWorkerWithProcessId, |
| + base::Bind(&EmbeddedWorkerRegistry::WorkerProcessAllocated, |
| this, |
| - embedded_worker_id, |
| base::Passed(¶ms), |
| callback)); |
| } |
| @@ -210,14 +212,13 @@ EmbeddedWorkerRegistry::~EmbeddedWorkerRegistry() { |
| Shutdown(); |
| } |
| -void EmbeddedWorkerRegistry::StartWorkerWithProcessId( |
| - int embedded_worker_id, |
| +void EmbeddedWorkerRegistry::WorkerProcessAllocated( |
| scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, |
| const StatusCallback& callback, |
| ServiceWorkerStatusCode status, |
| int process_id) { |
| WorkerInstanceMap::const_iterator worker = |
| - worker_map_.find(embedded_worker_id); |
| + worker_map_.find(params->embedded_worker_id); |
| if (worker == worker_map_.end()) { |
| // The Instance was destroyed before it could finish starting. Undo what |
| // we've done so far. |
| @@ -226,25 +227,37 @@ void EmbeddedWorkerRegistry::StartWorkerWithProcessId( |
| callback.Run(SERVICE_WORKER_ERROR_ABORT); |
| return; |
| } |
| - if (status == SERVICE_WORKER_OK) { |
| - // Gets the new routing id for the renderer process. |
| - scoped_refptr<RenderWidgetHelper> helper( |
| - RenderWidgetHelper::FromProcessHostID(process_id)); |
| - // |helper| may be NULL in unittest. |
| - params->worker_devtools_agent_route_id = |
| - helper ? helper->GetNextRoutingID() : MSG_ROUTING_NONE; |
| - } |
| - worker->second->RecordProcessId( |
| - process_id, status, params->worker_devtools_agent_route_id); |
| - |
| if (status != SERVICE_WORKER_OK) { |
| + worker->second->WorkerProcessAllocationFailed(); |
| callback.Run(status); |
| return; |
| } |
| + worker->second->WorkerProcessAllocated( |
| + process_id, |
| + base::Bind(&EmbeddedWorkerRegistry::StartWorkerWithProcessId, |
| + this, |
| + base::Passed(¶ms), |
| + callback, |
| + process_id)); |
|
kinuko
2014/05/08 11:17:31
The call sequence for starting a worker is becomin
horo
2014/05/08 14:17:46
I think we need to go through Registry after the t
kinuko
2014/05/08 16:34:57
Ok thanks, but I'm not fully convinced by the curr
horo
2014/05/12 10:18:49
Done.
|
| +} |
| + |
| +void EmbeddedWorkerRegistry::StartWorkerWithProcessId( |
| + scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, |
| + const StatusCallback& callback, |
| + int process_id, |
| + int worker_devtools_agent_route_id, |
| + bool pause_on_start) { |
| + WorkerInstanceMap::const_iterator worker = |
| + worker_map_.find(params->embedded_worker_id); |
| + DCHECK(worker != worker_map_.end()); |
| + worker->second->set_worker_devtools_agent_route_id( |
| + worker_devtools_agent_route_id); |
| // 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(ContainsKey(process_sender_map_, process_id)); |
| + params->worker_devtools_agent_route_id = worker_devtools_agent_route_id; |
| + params->pause_on_start = pause_on_start; |
| callback.Run(Send(process_id, new EmbeddedWorkerMsg_StartWorker(*params))); |
| } |