Chromium Code Reviews| Index: content/worker/websharedworker_stub.cc |
| diff --git a/content/worker/websharedworker_stub.cc b/content/worker/websharedworker_stub.cc |
| index ef642a0893adf1671833144fac2584e88c107413..e2192a9df42b4c27b2f8bda11b9f63a08d88530b 100644 |
| --- a/content/worker/websharedworker_stub.cc |
| +++ b/content/worker/websharedworker_stub.cc |
| @@ -4,10 +4,13 @@ |
| #include "content/worker/websharedworker_stub.h" |
| +#include "content/common/child_process.h" |
| #include "content/common/child_thread.h" |
| #include "content/common/file_system/file_system_dispatcher.h" |
| #include "content/common/webmessageportchannel_impl.h" |
| #include "content/common/worker_messages.h" |
| +#include "base/compiler_specific.h" |
| +#include "content/worker/worker_thread.h" |
| #include "content/worker/shared_worker_devtools_agent.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorker.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| @@ -16,10 +19,20 @@ |
| WebSharedWorkerStub::WebSharedWorkerStub( |
| const string16& name, int route_id, |
| const WorkerAppCacheInitInfo& appcache_init_info) |
| - : WebWorkerStubBase(route_id, appcache_init_info), |
| + : route_id_(route_id), |
| + appcache_init_info_(appcache_init_info), |
| + ALLOW_THIS_IN_INITIALIZER_LIST(client_(route_id, this)), |
| name_(name), |
| started_(false), |
| worker_devtools_agent_(NULL) { |
| + |
| + WorkerThread* workerThread = WorkerThread::current(); |
|
jam
2011/10/26 22:25:38
nit: worker_thread (i know it was like that before
|
| + DCHECK(workerThread); |
| + workerThread->AddWorkerStub(this); |
| + // Start processing incoming IPCs for this worker. |
| + workerThread->AddRoute(route_id_, this); |
| + ChildProcess::current()->AddRefProcess(); |
| + |
| // TODO(atwilson): Add support for NaCl when they support MessagePorts. |
| impl_ = WebKit::WebSharedWorker::create(client()); |
| worker_devtools_agent_.reset(new SharedWorkerDevToolsAgent(route_id, impl_)); |
| @@ -28,6 +41,20 @@ WebSharedWorkerStub::WebSharedWorkerStub( |
| WebSharedWorkerStub::~WebSharedWorkerStub() { |
| impl_->clientDestroyed(); |
| + WorkerThread* workerThread = WorkerThread::current(); |
| + DCHECK(workerThread); |
| + workerThread->RemoveWorkerStub(this); |
| + workerThread->RemoveRoute(route_id_); |
| + ChildProcess::current()->ReleaseProcess(); |
| +} |
| + |
| +void WebSharedWorkerStub::Shutdown() { |
| + // The worker has exited - free ourselves and the client. |
| + delete this; |
| +} |
| + |
| +void WebSharedWorkerStub::EnsureWorkerContextTerminates() { |
| + client_.EnsureWorkerContextTerminates(); |
| } |
| bool WebSharedWorkerStub::OnMessageReceived(const IPC::Message& message) { |
| @@ -49,7 +76,7 @@ void WebSharedWorkerStub::OnChannelError() { |
| OnTerminateWorkerContext(); |
| } |
| -const GURL& WebSharedWorkerStub::url() const { |
| +const GURL& WebSharedWorkerStub::url() { |
| return url_; |
| } |