Chromium Code Reviews| Index: content/renderer/websharedworker_proxy.cc |
| diff --git a/content/renderer/websharedworker_proxy.cc b/content/renderer/websharedworker_proxy.cc |
| index 3cf6f0cf8bf931fc4f6343516243d6289ed6ea4e..27eefefb7c6089b783c4838e8bc812567f03e8ab 100644 |
| --- a/content/renderer/websharedworker_proxy.cc |
| +++ b/content/renderer/websharedworker_proxy.cc |
| @@ -6,22 +6,25 @@ |
| #include <stddef.h> |
| +#include "content/child/child_thread_impl.h" |
| #include "content/child/webmessageportchannel_impl.h" |
| #include "content/common/view_messages.h" |
| #include "content/common/worker_messages.h" |
| +#include "ipc/ipc_sync_channel.h" |
| #include "ipc/message_router.h" |
| #include "third_party/WebKit/public/platform/WebURL.h" |
| #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" |
| namespace content { |
| -WebSharedWorkerProxy::WebSharedWorkerProxy(IPC::MessageRouter* router, |
| - int route_id) |
| +WebSharedWorkerProxy::WebSharedWorkerProxy(int route_id) |
| : route_id_(route_id), |
| - router_(router), |
| + router_(ChildThreadImpl::current()->GetRouter()), |
| connect_listener_(nullptr), |
| created_(false) { |
| router_->AddRoute(route_id_, this); |
| + ChildThreadImpl::current()->channel()->GetRemoteAssociatedInterface( |
| + &message_filter_); |
| } |
| WebSharedWorkerProxy::~WebSharedWorkerProxy() { |
| @@ -32,39 +35,29 @@ void WebSharedWorkerProxy::Disconnect() { |
| if (route_id_ == MSG_ROUTING_NONE) |
| return; |
| - // So the messages from WorkerContext (like WorkerContextDestroyed) do not |
| - // come after nobody is listening. Since Worker and WorkerContext can |
| - // terminate independently, already sent messages may still be in the pipe. |
| - router_->RemoveRoute(route_id_); |
| - |
| route_id_ = MSG_ROUTING_NONE; |
| } |
| -bool WebSharedWorkerProxy::Send(std::unique_ptr<IPC::Message> message) { |
| +bool WebSharedWorkerProxy::Send(int message_port_id) { |
|
nhiroki
2016/12/28 09:37:02
TODO(nhiroki): Make this void.
kinuko
2017/01/05 08:13:14
Doesn't 'Send' sound too generic?
nhiroki
2017/01/10 08:44:06
This function was removed by other cleanup CLs.
|
| // It's possible that messages will be sent before the worker is created, in |
| // which case route_id_ will be none. Or the worker object can be interacted |
| // with before the browser process told us that it started, in which case we |
| // also want to queue the message. |
| if (!created_) { |
| - queued_messages_.push_back(std::move(message)); |
| + queued_messages_.push_back(message_port_id); |
| return true; |
| } |
| - // For now we proxy all messages to the worker process through the browser. |
| - // Revisit if we find this slow. |
| // TODO(jabdelmalek): handle sync messages if we need them. |
| - return router_->Send(message.release()); |
| + message_filter_->OnConnectToWorker(route_id_, message_port_id); |
| + return true; |
| } |
| void WebSharedWorkerProxy::SendQueuedMessages() { |
| DCHECK(created_); |
| DCHECK(queued_messages_.size()); |
| - std::vector<std::unique_ptr<IPC::Message>> queued_messages; |
| - queued_messages.swap(queued_messages_); |
| - for (size_t i = 0; i < queued_messages.size(); ++i) { |
| - queued_messages[i]->set_routing_id(route_id_); |
| - Send(std::move(queued_messages[i])); |
| - } |
| + for (size_t i = 0; i < queued_messages_.size(); ++i) |
|
shimazu
2017/01/05 02:24:03
How about range-based for?
nhiroki
2017/01/10 08:44:06
This part was removed by other cleanup CLs.
|
| + Send(queued_messages_[i]); |
| } |
| void WebSharedWorkerProxy::connect(blink::WebMessagePortChannel* channel, |
| @@ -76,8 +69,7 @@ void WebSharedWorkerProxy::connect(blink::WebMessagePortChannel* channel, |
| DCHECK_NE(MSG_ROUTING_NONE, message_port_id); |
| webchannel->QueueMessages(); |
| - Send(base::MakeUnique<ViewHostMsg_ConnectToWorker>(route_id_, |
| - message_port_id)); |
| + Send(message_port_id); |
| connect_listener_ = listener; |
| } |