Chromium Code Reviews| Index: content/browser/shared_worker/shared_worker_host.cc |
| diff --git a/content/browser/shared_worker/shared_worker_host.cc b/content/browser/shared_worker/shared_worker_host.cc |
| index eb58399bc9466779b549c3e79d713419d1d328c3..69e7380b4d53757f3810073eed3a600ccfcb9fa7 100644 |
| --- a/content/browser/shared_worker/shared_worker_host.cc |
| +++ b/content/browser/shared_worker/shared_worker_host.cc |
| @@ -4,15 +4,18 @@ |
| #include "content/browser/shared_worker/shared_worker_host.h" |
| +#include "content/browser/devtools/shared_worker_devtools_manager.h" |
| #include "content/browser/frame_host/render_frame_host_delegate.h" |
| #include "content/browser/frame_host/render_frame_host_impl.h" |
| #include "content/browser/message_port_service.h" |
| #include "content/browser/shared_worker/shared_worker_instance.h" |
| #include "content/browser/shared_worker/shared_worker_message_filter.h" |
| +#include "content/browser/shared_worker/shared_worker_service_impl.h" |
| #include "content/common/view_messages.h" |
| #include "content/common/worker_messages.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/content_browser_client.h" |
| +#include "content/public/browser/render_process_host.h" |
| #include "content/public/common/content_client.h" |
| namespace content { |
| @@ -26,6 +29,27 @@ void WorkerCrashCallback(int render_process_unique_id, int render_frame_id) { |
| host->delegate()->WorkerCrashed(host); |
| } |
| +void WorkerCreatedOnUI(int worker_process_id, |
| + int worker_route_id, |
| + const GURL& url, |
| + const base::string16& name) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + SharedWorkerDevToolsManager::GetInstance()->WorkerCreated( |
| + worker_process_id, worker_route_id, url, name); |
| +} |
| + |
| +void WorkerScriptLoadedOnUI(int worker_process_id, int worker_route_id) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + SharedWorkerDevToolsManager::GetInstance()->WorkerContextStarted( |
| + worker_process_id, worker_route_id); |
| +} |
| + |
| +void WorkerDestroyedOnUI(int worker_process_id, int worker_route_id) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + SharedWorkerDevToolsManager::GetInstance()->WorkerDestroyed( |
| + worker_process_id, worker_route_id); |
| +} |
| + |
| } // namespace |
| SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance) |
| @@ -52,6 +76,13 @@ SharedWorkerHost::~SharedWorkerHost() { |
| parent_iter->render_frame_id())); |
| } |
| } |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind( |
| + &WorkerDestroyedOnUI, worker_process_id_, worker_route_id_)); |
| + SharedWorkerServiceImpl::GetInstance()->NotifyWorkerDestroyed( |
| + worker_process_id_, worker_route_id_); |
| } |
| bool SharedWorkerHost::Send(IPC::Message* message) { |
| @@ -66,8 +97,17 @@ void SharedWorkerHost::Init(SharedWorkerMessageFilter* filter) { |
| CHECK(instance_); |
| DCHECK(worker_route_id_ == MSG_ROUTING_NONE); |
| container_render_filter_ = filter; |
| + worker_process_id_ = filter->render_process_id(); |
| worker_route_id_ = filter->GetNextRoutingID(); |
| + BrowserThread::PostTask(BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(WorkerCreatedOnUI, |
|
kinuko
2014/03/24 12:24:02
& is missing?
horo
2014/03/25 06:28:17
Done.
|
| + worker_process_id_, |
| + worker_route_id_, |
| + instance_->url(), |
| + instance_->name())); |
| + |
| WorkerProcessMsg_CreateWorker_Params params; |
| params.url = instance_->url(); |
| params.name = instance_->name(); |
| @@ -130,13 +170,15 @@ void SharedWorkerHost::WorkerContextClosed() { |
| } |
| void SharedWorkerHost::WorkerContextDestroyed() { |
| - if (!instance_) |
| - return; |
| instance_.reset(); |
| } |
| void SharedWorkerHost::WorkerScriptLoaded() { |
| - // TODO(horo): implement this. |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind( |
| + &WorkerScriptLoadedOnUI, worker_process_id_, worker_route_id_)); |
| } |
| void SharedWorkerHost::WorkerScriptLoadFailed() { |