| Index: content/browser/service_worker/service_worker_process_manager.cc
|
| diff --git a/content/browser/service_worker/service_worker_process_manager.cc b/content/browser/service_worker/service_worker_process_manager.cc
|
| index b6a2891e2d2254d718312c68c5daee83369051a3..3306e15652db056d2a338281660e9cace4cc179c 100644
|
| --- a/content/browser/service_worker/service_worker_process_manager.cc
|
| +++ b/content/browser/service_worker/service_worker_process_manager.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "content/browser/service_worker/service_worker_process_manager.h"
|
|
|
| +#include "content/browser/devtools/embedded_worker_devtools_manager.h"
|
| #include "content/browser/renderer_host/render_process_host_impl.h"
|
| #include "content/browser/service_worker/service_worker_context_wrapper.h"
|
| #include "content/public/browser/browser_thread.h"
|
| @@ -12,6 +13,27 @@
|
|
|
| namespace content {
|
|
|
| +namespace {
|
| +
|
| +void GetRoutingIDAndNotifyWorkerCreated(RenderProcessHost* rph,
|
| + const base::FilePath& path,
|
| + const GURL& scope,
|
| + int* route_id,
|
| + bool* pause_on_start) {
|
| + if (!rph) {
|
| + // |rph| may NULL in unit tests.
|
| + *route_id = MSG_ROUTING_NONE;
|
| + *pause_on_start = false;
|
| + return;
|
| + }
|
| + *route_id = rph->GetNextRoutingID();
|
| + *pause_on_start =
|
| + EmbeddedWorkerDevToolsManager::GetInstance()->ServiceWorkerCreated(
|
| + rph->GetID(), *route_id, path, scope);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| ServiceWorkerProcessManager::ServiceWorkerProcessManager(
|
| ServiceWorkerContextWrapper* context_wrapper)
|
| : context_wrapper_(context_wrapper),
|
| @@ -25,9 +47,13 @@ ServiceWorkerProcessManager::~ServiceWorkerProcessManager() {
|
|
|
| void ServiceWorkerProcessManager::AllocateWorkerProcess(
|
| const std::vector<int>& process_ids,
|
| + const base::FilePath& path,
|
| + const GURL& scope,
|
| const GURL& script_url,
|
| - const base::Callback<void(ServiceWorkerStatusCode, int process_id)>&
|
| - callback) const {
|
| + const base::Callback<void(ServiceWorkerStatusCode,
|
| + int process_id,
|
| + int worker_devtools_agent_route_id,
|
| + bool pause_on_start)>& callback) const {
|
| if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
|
| BrowserThread::PostTask(
|
| BrowserThread::UI,
|
| @@ -35,28 +61,41 @@ void ServiceWorkerProcessManager::AllocateWorkerProcess(
|
| base::Bind(&ServiceWorkerProcessManager::AllocateWorkerProcess,
|
| weak_this_,
|
| process_ids,
|
| + path,
|
| + scope,
|
| script_url,
|
| callback));
|
| return;
|
| }
|
| -
|
| + int route_id = MSG_ROUTING_NONE;
|
| + bool pause_on_start = false;
|
| for (std::vector<int>::const_iterator it = process_ids.begin();
|
| it != process_ids.end();
|
| ++it) {
|
| if (IncrementWorkerRefcountByPid(*it)) {
|
| - BrowserThread::PostTask(BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, SERVICE_WORKER_OK, *it));
|
| + GetRoutingIDAndNotifyWorkerCreated(RenderProcessHost::FromID(*it),
|
| + path,
|
| + scope,
|
| + &route_id,
|
| + &pause_on_start);
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(
|
| + callback, SERVICE_WORKER_OK, *it, route_id, pause_on_start));
|
| return;
|
| }
|
| }
|
|
|
| if (!context_wrapper_->browser_context_) {
|
| // Shutdown has started.
|
| - BrowserThread::PostTask(
|
| - BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED, -1));
|
| + BrowserThread::PostTask(BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(callback,
|
| + SERVICE_WORKER_ERROR_START_WORKER_FAILED,
|
| + -1,
|
| + route_id,
|
| + pause_on_start));
|
| return;
|
| }
|
| // No existing processes available; start a new one.
|
| @@ -68,18 +107,24 @@ void ServiceWorkerProcessManager::AllocateWorkerProcess(
|
| // EmbeddedWorkerRegistry::process_sender_map_.
|
| if (!rph->Init()) {
|
| LOG(ERROR) << "Couldn't start a new process!";
|
| - BrowserThread::PostTask(
|
| - BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED, -1));
|
| + BrowserThread::PostTask(BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(callback,
|
| + SERVICE_WORKER_ERROR_START_WORKER_FAILED,
|
| + -1,
|
| + route_id,
|
| + pause_on_start));
|
| return;
|
| }
|
|
|
| static_cast<RenderProcessHostImpl*>(rph)->IncrementWorkerRefCount();
|
| + GetRoutingIDAndNotifyWorkerCreated(
|
| + rph, path, scope, &route_id, &pause_on_start);
|
| BrowserThread::PostTask(
|
| BrowserThread::IO,
|
| FROM_HERE,
|
| - base::Bind(callback, SERVICE_WORKER_OK, rph->GetID()));
|
| + base::Bind(
|
| + callback, SERVICE_WORKER_OK, rph->GetID(), route_id, pause_on_start));
|
| }
|
|
|
| void ServiceWorkerProcessManager::ReleaseWorkerProcess(int process_id) {
|
|
|