diff options
author | horo@chromium.org <horo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-29 17:29:25 +0000 |
---|---|---|
committer | horo@chromium.org <horo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-29 17:29:25 +0000 |
commit | aa669a6b594371967bcbd9255fb5855a1ac3ea36 (patch) | |
tree | 43b6d9caae985c6c8b3a3f5cbf9863c6433cb5e5 | |
parent | c9a3337f4c80998e52c744533cf4c6a64d2eeb6b (diff) | |
download | chromium_src-aa669a6b594371967bcbd9255fb5855a1ac3ea36.zip chromium_src-aa669a6b594371967bcbd9255fb5855a1ac3ea36.tar.gz chromium_src-aa669a6b594371967bcbd9255fb5855a1ac3ea36.tar.bz2 |
Add pause_on_start flag to WorkerProcessMsg_CreateWorker_Params.
DevToolsAgentMsg_PauseWorkerContextOnStart was send to the worker process from the browser process in order to pause the worker context when it starts.
Before http://crbug.com/329786 this message was sent between WorkerProcessMsg_CreateWorker and WorkerMsg_StartWorkerContext.
So the worker was successfully paused before started.
But after http://crbug.com/329786 the worker context may be started before the worker process receives this message because WorkerMsg_StartWorkerContext is no longer sent from the browser process.
So we have to add pause_on_start flag to WorkerProcessMsg_CreateWorker_Params to pause the worker context correctly.
BUG=329786
Review URL: https://codereview.chromium.org/213423008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260377 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/devtools/worker_devtools_manager.cc | 7 | ||||
-rw-r--r-- | content/browser/devtools/worker_devtools_manager.h | 3 | ||||
-rw-r--r-- | content/browser/worker_host/worker_process_host.cc | 4 | ||||
-rw-r--r-- | content/browser/worker_host/worker_process_host.h | 2 | ||||
-rw-r--r-- | content/browser/worker_host/worker_service_impl.cc | 5 | ||||
-rw-r--r-- | content/child/shared_worker_devtools_agent.cc | 6 | ||||
-rw-r--r-- | content/child/shared_worker_devtools_agent.h | 1 | ||||
-rw-r--r-- | content/common/devtools_messages.h | 5 | ||||
-rw-r--r-- | content/common/worker_messages.h | 1 | ||||
-rw-r--r-- | content/worker/websharedworker_stub.cc | 6 | ||||
-rw-r--r-- | content/worker/websharedworker_stub.h | 1 | ||||
-rw-r--r-- | content/worker/worker_thread.cc | 1 |
12 files changed, 21 insertions, 21 deletions
diff --git a/content/browser/devtools/worker_devtools_manager.cc b/content/browser/devtools/worker_devtools_manager.cc index 00735f34..62f77e7 100644 --- a/content/browser/devtools/worker_devtools_manager.cc +++ b/content/browser/devtools/worker_devtools_manager.cc @@ -228,7 +228,7 @@ WorkerDevToolsManager::WorkerDevToolsManager() { WorkerDevToolsManager::~WorkerDevToolsManager() { } -void WorkerDevToolsManager::WorkerCreated( +bool WorkerDevToolsManager::WorkerCreated( WorkerProcessHost* worker, const WorkerProcessHost::WorkerInstance& instance) { for (TerminatedInspectedWorkers::iterator it = terminated_workers_.begin(); @@ -236,14 +236,13 @@ void WorkerDevToolsManager::WorkerCreated( if (instance.Matches(it->worker_url, it->worker_name, instance.partition(), instance.resource_context())) { - worker->Send(new DevToolsAgentMsg_PauseWorkerContextOnStart( - instance.worker_route_id())); WorkerId new_worker_id(worker->GetData().id, instance.worker_route_id()); paused_workers_[new_worker_id] = it->old_worker_id; terminated_workers_.erase(it); - return; + return true; } } + return false; } void WorkerDevToolsManager::WorkerDestroyed( diff --git a/content/browser/devtools/worker_devtools_manager.h b/content/browser/devtools/worker_devtools_manager.h index 7ea8840..a70f178 100644 --- a/content/browser/devtools/worker_devtools_manager.h +++ b/content/browser/devtools/worker_devtools_manager.h @@ -40,7 +40,8 @@ class WorkerDevToolsManager { const std::string& state); // Called on the IO thread. - void WorkerCreated( + // Returns true when the worker must be paused on start. + bool WorkerCreated( WorkerProcessHost* process, const WorkerProcessHost::WorkerInstance& instance); void WorkerDestroyed(WorkerProcessHost* process, int worker_route_id); diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc index 24abf8e..4fb67e8 100644 --- a/content/browser/worker_host/worker_process_host.cc +++ b/content/browser/worker_host/worker_process_host.cc @@ -323,7 +323,8 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) { new IndexedDBDispatcherHost(partition_.indexed_db_context())); } -void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { +void WorkerProcessHost::CreateWorker(const WorkerInstance& instance, + bool pause_on_start) { ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( process_->GetData().id, instance.url()); @@ -334,6 +335,7 @@ void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { params.name = instance.name(); params.content_security_policy = instance.content_security_policy(); params.security_policy_type = instance.security_policy_type(); + params.pause_on_start = pause_on_start; params.route_id = instance.worker_route_id(); Send(new WorkerProcessMsg_CreateWorker(params)); diff --git a/content/browser/worker_host/worker_process_host.h b/content/browser/worker_host/worker_process_host.h index c363168..10ea12a 100644 --- a/content/browser/worker_host/worker_process_host.h +++ b/content/browser/worker_host/worker_process_host.h @@ -170,7 +170,7 @@ class WorkerProcessHost : public BrowserChildProcessHostDelegate, bool Init(int render_process_id, int render_frame_id); // Creates a worker object in the process. - void CreateWorker(const WorkerInstance& instance); + void CreateWorker(const WorkerInstance& instance, bool pause_on_start); // Returns true iff the given message from a renderer process was forwarded to // the worker. diff --git a/content/browser/worker_host/worker_service_impl.cc b/content/browser/worker_host/worker_service_impl.cc index d17f440..5064544 100644 --- a/content/browser/worker_host/worker_service_impl.cc +++ b/content/browser/worker_host/worker_service_impl.cc @@ -409,12 +409,13 @@ bool WorkerServiceImpl::CreateWorkerFromInstance( return false; } - worker->CreateWorker(instance); + worker->CreateWorker( + instance, + WorkerDevToolsManager::GetInstance()->WorkerCreated(worker, instance)); FOR_EACH_OBSERVER( WorkerServiceObserver, observers_, WorkerCreated(instance.url(), instance.name(), worker->GetData().id, instance.worker_route_id())); - WorkerDevToolsManager::GetInstance()->WorkerCreated(worker, instance); return true; } diff --git a/content/child/shared_worker_devtools_agent.cc b/content/child/shared_worker_devtools_agent.cc index 475f55f..853d08e 100644 --- a/content/child/shared_worker_devtools_agent.cc +++ b/content/child/shared_worker_devtools_agent.cc @@ -34,8 +34,6 @@ bool SharedWorkerDevToolsAgent::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, OnDispatchOnInspectorBackend) - IPC_MESSAGE_HANDLER(DevToolsAgentMsg_PauseWorkerContextOnStart, - OnPauseWorkerContextOnStart) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_ResumeWorkerContext, OnResumeWorkerContext) IPC_MESSAGE_UNHANDLED(handled = false) @@ -73,10 +71,6 @@ void SharedWorkerDevToolsAgent::OnDispatchOnInspectorBackend( webworker_->dispatchDevToolsMessage(WebString::fromUTF8(message)); } -void SharedWorkerDevToolsAgent::OnPauseWorkerContextOnStart() { - webworker_->pauseWorkerContextOnStart(); -} - void SharedWorkerDevToolsAgent::OnResumeWorkerContext() { webworker_->resumeWorkerContext(); } diff --git a/content/child/shared_worker_devtools_agent.h b/content/child/shared_worker_devtools_agent.h index 8106989..c8a4655 100644 --- a/content/child/shared_worker_devtools_agent.h +++ b/content/child/shared_worker_devtools_agent.h @@ -35,7 +35,6 @@ class SharedWorkerDevToolsAgent { void OnReattach(const std::string&); void OnDetach(); void OnDispatchOnInspectorBackend(const std::string& message); - void OnPauseWorkerContextOnStart(); void OnResumeWorkerContext(); bool Send(IPC::Message* message); diff --git a/content/common/devtools_messages.h b/content/common/devtools_messages.h index cd4c4b5..8815a43 100644 --- a/content/common/devtools_messages.h +++ b/content/common/devtools_messages.h @@ -86,11 +86,6 @@ IPC_MESSAGE_ROUTED2(DevToolsAgentMsg_AddMessageToConsole, content::ConsoleMessageLevel /* level */, std::string /* message */) -// Notifies worker devtools agent that it should pause worker context -// when it starts and wait until either DevTools client is attached or -// explicit resume notification is received. -IPC_MESSAGE_ROUTED0(DevToolsAgentMsg_PauseWorkerContextOnStart) - // Worker DevTools agent should resume worker execution. IPC_MESSAGE_ROUTED0(DevToolsAgentMsg_ResumeWorkerContext) diff --git a/content/common/worker_messages.h b/content/common/worker_messages.h index 3cc6a6f..743d22f 100644 --- a/content/common/worker_messages.h +++ b/content/common/worker_messages.h @@ -42,6 +42,7 @@ IPC_STRUCT_BEGIN(WorkerProcessMsg_CreateWorker_Params) IPC_STRUCT_MEMBER(base::string16, name) IPC_STRUCT_MEMBER(base::string16, content_security_policy) IPC_STRUCT_MEMBER(blink::WebContentSecurityPolicyType, security_policy_type) + IPC_STRUCT_MEMBER(bool, pause_on_start) IPC_STRUCT_MEMBER(int, route_id) IPC_STRUCT_END() diff --git a/content/worker/websharedworker_stub.cc b/content/worker/websharedworker_stub.cc index fd33a61..474feb3 100644 --- a/content/worker/websharedworker_stub.cc +++ b/content/worker/websharedworker_stub.cc @@ -23,6 +23,7 @@ WebSharedWorkerStub::WebSharedWorkerStub( const base::string16& name, const base::string16& content_security_policy, blink::WebContentSecurityPolicyType security_policy_type, + bool pause_on_start, int route_id) : route_id_(route_id), client_(route_id, this), @@ -37,6 +38,11 @@ WebSharedWorkerStub::WebSharedWorkerStub( // TODO(atwilson): Add support for NaCl when they support MessagePorts. impl_ = blink::WebSharedWorker::create(client()); + if (pause_on_start) { + // Pause worker context when it starts and wait until either DevTools client + // is attached or explicit resume notification is received. + impl_->pauseWorkerContextOnStart(); + } worker_devtools_agent_.reset(new SharedWorkerDevToolsAgent(route_id, impl_)); client()->set_devtools_agent(worker_devtools_agent_.get()); impl_->startWorkerContext(url_, name, diff --git a/content/worker/websharedworker_stub.h b/content/worker/websharedworker_stub.h index 1f9aadd..c1a6287 100644 --- a/content/worker/websharedworker_stub.h +++ b/content/worker/websharedworker_stub.h @@ -30,6 +30,7 @@ class WebSharedWorkerStub : public IPC::Listener { const base::string16& name, const base::string16& content_security_policy, blink::WebContentSecurityPolicyType security_policy_type, + bool pause_on_start, int route_id); // IPC::Listener implementation. diff --git a/content/worker/worker_thread.cc b/content/worker/worker_thread.cc index 8425c16..687637b 100644 --- a/content/worker/worker_thread.cc +++ b/content/worker/worker_thread.cc @@ -123,6 +123,7 @@ void WorkerThread::OnCreateWorker( params.name, params.content_security_policy, params.security_policy_type, + params.pause_on_start, params.route_id); } |