| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 5 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
| 8 #include "content/child/scoped_child_process_reference.h" | 8 #include "content/child/scoped_child_process_reference.h" |
| 9 #include "content/child/shared_worker_devtools_agent.h" | 9 #include "content/child/shared_worker_devtools_agent.h" |
| 10 #include "content/child/webmessageportchannel_impl.h" | 10 #include "content/child/webmessageportchannel_impl.h" |
| 11 #include "content/common/worker_messages.h" | 11 #include "content/common/worker_messages.h" |
| 12 #include "content/renderer/render_thread_impl.h" | 12 #include "content/renderer/render_thread_impl.h" |
| 13 #include "ipc/ipc_message_macros.h" | 13 #include "ipc/ipc_message_macros.h" |
| 14 #include "third_party/WebKit/public/web/WebSharedWorker.h" | 14 #include "third_party/WebKit/public/web/WebSharedWorker.h" |
| 15 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" | 15 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub( | 19 EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub( |
| 20 const GURL& url, | 20 const GURL& url, |
| 21 const base::string16& name, | 21 const base::string16& name, |
| 22 const base::string16& content_security_policy, | 22 const base::string16& content_security_policy, |
| 23 blink::WebContentSecurityPolicyType security_policy_type, | 23 blink::WebContentSecurityPolicyType security_policy_type, |
| 24 int route_id) | 24 int route_id) |
| 25 : route_id_(route_id), | 25 : route_id_(route_id), |
| 26 name_(name), | 26 name_(name), |
| 27 runing_(false), | 27 runing_(false), |
| 28 url_(url) { | 28 url_(url) { |
| 29 RenderThreadImpl::current()->AddRoute(route_id_, this); | 29 RenderThreadImpl::current()->AddSharedWorkerRoute(route_id_, this); |
| 30 impl_ = blink::WebSharedWorker::create(this); | 30 impl_ = blink::WebSharedWorker::create(this); |
| 31 worker_devtools_agent_.reset( | 31 worker_devtools_agent_.reset( |
| 32 new SharedWorkerDevToolsAgent(route_id, impl_)); | 32 new SharedWorkerDevToolsAgent(route_id, impl_)); |
| 33 impl_->startWorkerContext(url, name_, | 33 impl_->startWorkerContext(url, name_, |
| 34 content_security_policy, security_policy_type); | 34 content_security_policy, security_policy_type); |
| 35 } | 35 } |
| 36 | 36 |
| 37 EmbeddedSharedWorkerStub::~EmbeddedSharedWorkerStub() { | 37 EmbeddedSharedWorkerStub::~EmbeddedSharedWorkerStub() { |
| 38 RenderThreadImpl::current()->RemoveRoute(route_id_); | 38 RenderThreadImpl::current()->RemoveSharedWorkerRoute(route_id_); |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool EmbeddedSharedWorkerStub::OnMessageReceived( | 41 bool EmbeddedSharedWorkerStub::OnMessageReceived( |
| 42 const IPC::Message& message) { | 42 const IPC::Message& message) { |
| 43 if (worker_devtools_agent_->OnMessageReceived(message)) | 43 if (worker_devtools_agent_->OnMessageReceived(message)) |
| 44 return true; | 44 return true; |
| 45 bool handled = true; | 45 bool handled = true; |
| 46 IPC_BEGIN_MESSAGE_MAP(EmbeddedSharedWorkerStub, message) | 46 IPC_BEGIN_MESSAGE_MAP(EmbeddedSharedWorkerStub, message) |
| 47 IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext, | 47 IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext, |
| 48 OnTerminateWorkerContext) | 48 OnTerminateWorkerContext) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 pending_channels_.push_back(channel); | 155 pending_channels_.push_back(channel); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { | 159 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { |
| 160 runing_ = false; | 160 runing_ = false; |
| 161 impl_->terminateWorkerContext(); | 161 impl_->terminateWorkerContext(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace content | 164 } // namespace content |
| OLD | NEW |