diff options
16 files changed, 141 insertions, 269 deletions
diff --git a/content/browser/message_port_message_filter.cc b/content/browser/message_port_message_filter.cc deleted file mode 100644 index 1c08497..0000000 --- a/content/browser/message_port_message_filter.cc +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/message_port_message_filter.h" - -#include "content/browser/message_port_service.h" -#include "content/common/message_port_messages.h" - -namespace content { - -MessagePortMessageFilter::MessagePortMessageFilter( - const NextRoutingIDCallback& callback) - : next_routing_id_(callback) { -} - -MessagePortMessageFilter::~MessagePortMessageFilter() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); -} - -void MessagePortMessageFilter::OnChannelClosing() { - MessagePortService::GetInstance()->OnMessagePortMessageFilterClosing(this); -} - -bool MessagePortMessageFilter::OnMessageReceived(const IPC::Message& message, - bool* message_was_ok) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(MessagePortMessageFilter, message, *message_was_ok) - IPC_MESSAGE_HANDLER(MessagePortHostMsg_CreateMessagePort, - OnCreateMessagePort) - IPC_MESSAGE_FORWARD(MessagePortHostMsg_DestroyMessagePort, - MessagePortService::GetInstance(), - MessagePortService::Destroy) - IPC_MESSAGE_FORWARD(MessagePortHostMsg_Entangle, - MessagePortService::GetInstance(), - MessagePortService::Entangle) - IPC_MESSAGE_FORWARD(MessagePortHostMsg_PostMessage, - MessagePortService::GetInstance(), - MessagePortService::PostMessage) - IPC_MESSAGE_FORWARD(MessagePortHostMsg_QueueMessages, - MessagePortService::GetInstance(), - MessagePortService::QueueMessages) - IPC_MESSAGE_FORWARD(MessagePortHostMsg_SendQueuedMessages, - MessagePortService::GetInstance(), - MessagePortService::SendQueuedMessages) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP_EX() - - return handled; -} - -int MessagePortMessageFilter::GetNextRoutingID() { - return next_routing_id_.Run(); -} - -void MessagePortMessageFilter::OnCreateMessagePort(int *route_id, - int* message_port_id) { - *route_id = next_routing_id_.Run(); - MessagePortService::GetInstance()->Create(*route_id, this, message_port_id); -} - -} // namespace content diff --git a/content/browser/message_port_message_filter.h b/content/browser/message_port_message_filter.h deleted file mode 100644 index 592eba6..0000000 --- a/content/browser/message_port_message_filter.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_MESSAGE_PORT_MESSAGE_FILTER_H_ -#define CONTENT_BROWSER_MESSAGE_PORT_MESSAGE_FILTER_H_ - -#include "base/callback.h" -#include "content/public/browser/browser_message_filter.h" - -namespace content { - -// Filter for MessagePort related IPC messages (creating and destroying a -// MessagePort, sending a message via a MessagePort etc). -class MessagePortMessageFilter : public BrowserMessageFilter { - public: - typedef base::Callback<int(void)> NextRoutingIDCallback; - - // |next_routing_id| is owned by this object. It can be used up until - // OnChannelClosing. - explicit MessagePortMessageFilter(const NextRoutingIDCallback& callback); - - // BrowserMessageFilter implementation. - virtual void OnChannelClosing() OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& message, - bool* message_was_ok) OVERRIDE; - int GetNextRoutingID(); - - private: - virtual ~MessagePortMessageFilter(); - - // Message handlers. - void OnCreateMessagePort(int* route_id, int* message_port_id); - - // This is guaranteed to be valid until OnChannelClosing is invoked, and it's - // not used after. - NextRoutingIDCallback next_routing_id_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortMessageFilter); -}; - -} // namespace content - -#endif // CONTENT_BROWSER_WORKER_MESSAGE_FILTER_H_ diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index f6e3ed0..49ed5df 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -63,7 +63,6 @@ #include "content/browser/loader/resource_scheduler_filter.h" #include "content/browser/media/android/browser_demuxer_android.h" #include "content/browser/media/media_internals.h" -#include "content/browser/message_port_message_filter.h" #include "content/browser/mime_registry_message_filter.h" #include "content/browser/plugin_service_impl.h" #include "content/browser/profiler_message_filter.h" @@ -674,11 +673,6 @@ void RenderProcessHostImpl::CreateMessageFilters() { GetID(), request_context_callback, resource_context); AddFilter(socket_stream_dispatcher_host); - message_port_message_filter_ = new MessagePortMessageFilter( - base::Bind(&RenderWidgetHelper::GetNextRoutingID, - base::Unretained(widget_helper_.get()))); - AddFilter(message_port_message_filter_); - AddFilter(new WorkerMessageFilter( GetID(), resource_context, @@ -690,7 +684,8 @@ void RenderProcessHostImpl::CreateMessageFilters() { storage_partition_impl_->GetFileSystemContext(), storage_partition_impl_->GetDatabaseTracker(), storage_partition_impl_->GetIndexedDBContext()), - message_port_message_filter_)); + base::Bind(&RenderWidgetHelper::GetNextRoutingID, + base::Unretained(widget_helper_.get())))); #if defined(ENABLE_WEBRTC) AddFilter(new P2PSocketDispatcherHost( @@ -1345,7 +1340,6 @@ void RenderProcessHostImpl::Cleanup() { // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. channel_.reset(); gpu_message_filter_ = NULL; - message_port_message_filter_ = NULL; // Remove ourself from the list of renderer processes so that we can't be // reused in between now and when the Delete task runs. @@ -1644,7 +1638,6 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead) { child_process_launcher_.reset(); channel_.reset(); gpu_message_filter_ = NULL; - message_port_message_filter_ = NULL; IDMap<IPC::Listener>::iterator iter(&listeners_); while (!iter.IsAtEnd()) { diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h index 1287b2e..567b629b 100644 --- a/content/browser/renderer_host/render_process_host_impl.h +++ b/content/browser/renderer_host/render_process_host_impl.h @@ -35,7 +35,6 @@ class Size; namespace content { class BrowserDemuxerAndroid; class GpuMessageFilter; -class MessagePortMessageFilter; class PeerConnectionTrackerHost; class RendererMainThread; class RenderWidgetHelper; @@ -261,9 +260,6 @@ class CONTENT_EXPORT RenderProcessHostImpl // it's valid if non-NULL. GpuMessageFilter* gpu_message_filter_; - // The filter for MessagePort messages coming from the renderer. - scoped_refptr<MessagePortMessageFilter> message_port_message_filter_; - // A map of transport DIB ids to cached TransportDIBs std::map<TransportDIB::Id, TransportDIB*> cached_dibs_; diff --git a/content/browser/message_port_service.cc b/content/browser/worker_host/message_port_service.cc index bc2a1ac..3bc8f5a 100644 --- a/content/browser/message_port_service.cc +++ b/content/browser/worker_host/message_port_service.cc @@ -1,11 +1,11 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/message_port_service.h" +#include "content/browser/worker_host/message_port_service.h" -#include "content/browser/message_port_message_filter.h" -#include "content/common/message_port_messages.h" +#include "content/browser/worker_host/worker_message_filter.h" +#include "content/common/worker_messages.h" namespace content { @@ -13,7 +13,7 @@ struct MessagePortService::MessagePort { // |filter| and |route_id| are what we need to send messages to the port. // |filter| is just a weak pointer since we get notified when its process has // gone away and remove it. - MessagePortMessageFilter* filter; + WorkerMessageFilter* filter; int route_id; // A globally unique id for this message port. int message_port_id; @@ -26,7 +26,7 @@ struct MessagePortService::MessagePort { // in-flight. This flag ensures that the latter type get flushed through the // system. // This flag should only be set to true in response to - // MessagePortHostMsg_QueueMessages. + // WorkerProcessHostMsg_QueueMessages. bool queue_messages; QueuedMessages queued_messages; }; @@ -44,7 +44,7 @@ MessagePortService::~MessagePortService() { void MessagePortService::UpdateMessagePort( int message_port_id, - MessagePortMessageFilter* filter, + WorkerMessageFilter* filter, int routing_id) { if (!message_ports_.count(message_port_id)) { NOTREACHED(); @@ -56,8 +56,8 @@ void MessagePortService::UpdateMessagePort( port.route_id = routing_id; } -void MessagePortService::OnMessagePortMessageFilterClosing( - MessagePortMessageFilter* filter) { +void MessagePortService::OnWorkerMessageFilterClosing( + WorkerMessageFilter* filter) { // Check if the (possibly) crashed process had any message ports. for (MessagePorts::iterator iter = message_ports_.begin(); iter != message_ports_.end();) { @@ -69,7 +69,7 @@ void MessagePortService::OnMessagePortMessageFilterClosing( } void MessagePortService::Create(int route_id, - MessagePortMessageFilter* filter, + WorkerMessageFilter* filter, int* message_port_id) { *message_port_id = ++next_message_port_id_; @@ -173,7 +173,7 @@ void MessagePortService::PostMessageTo( } // Now send the message to the entangled port. - entangled_port.filter->Send(new MessagePortMsg_Message( + entangled_port.filter->Send(new WorkerProcessMsg_Message( entangled_port.route_id, message, sent_message_port_ids, new_routing_ids)); } @@ -186,7 +186,7 @@ void MessagePortService::QueueMessages(int message_port_id) { MessagePort& port = message_ports_[message_port_id]; if (port.filter) { - port.filter->Send(new MessagePortMsg_MessagesQueued(port.route_id)); + port.filter->Send(new WorkerProcessMsg_MessagesQueued(port.route_id)); port.queue_messages = true; port.filter = NULL; } diff --git a/content/browser/message_port_service.h b/content/browser/worker_host/message_port_service.h index 55e536c..b85e76b 100644 --- a/content/browser/message_port_service.h +++ b/content/browser/worker_host/message_port_service.h @@ -1,9 +1,9 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ -#define CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ +#ifndef CONTENT_BROWSER_WORKER_HOST_MESSAGE_PORT_SERVICE_H_ +#define CONTENT_BROWSER_WORKER_HOST_MESSAGE_PORT_SERVICE_H_ #include <map> #include <utility> @@ -15,7 +15,7 @@ #include "ipc/ipc_message.h" namespace content { -class MessagePortMessageFilter; +class WorkerMessageFilter; class MessagePortService { public: @@ -25,9 +25,7 @@ class MessagePortService { static MessagePortService* GetInstance(); // These methods correspond to the message port related IPCs. - void Create(int route_id, - MessagePortMessageFilter* filter, - int* message_port_id); + void Create(int route_id, WorkerMessageFilter* filter, int* message_port_id); void Destroy(int message_port_id); void Entangle(int local_message_port_id, int remote_message_port_id); void PostMessage(int sender_message_port_id, @@ -41,10 +39,10 @@ class MessagePortService { // (possibly different) process. void UpdateMessagePort( int message_port_id, - MessagePortMessageFilter* filter, + WorkerMessageFilter* filter, int routing_id); - void OnMessagePortMessageFilterClosing(MessagePortMessageFilter* filter); + void OnWorkerMessageFilterClosing(WorkerMessageFilter* filter); // Attempts to send the queued messages for a message port. void SendQueuedMessagesIfPossible(int message_port_id); @@ -75,4 +73,4 @@ class MessagePortService { } // namespace content -#endif // CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ +#endif // CONTENT_BROWSER_WORKER_HOST_MESSAGE_PORT_SERVICE_H_ diff --git a/content/browser/worker_host/worker_message_filter.cc b/content/browser/worker_host/worker_message_filter.cc index 49fe7f6..6631de3 100644 --- a/content/browser/worker_host/worker_message_filter.cc +++ b/content/browser/worker_host/worker_message_filter.cc @@ -4,7 +4,7 @@ #include "content/browser/worker_host/worker_message_filter.h" -#include "content/browser/message_port_message_filter.h" +#include "content/browser/worker_host/message_port_service.h" #include "content/browser/worker_host/worker_service_impl.h" #include "content/common/view_messages.h" #include "content/common/worker_messages.h" @@ -16,11 +16,11 @@ WorkerMessageFilter::WorkerMessageFilter( int render_process_id, ResourceContext* resource_context, const WorkerStoragePartition& partition, - MessagePortMessageFilter* message_port_message_filter) + const NextRoutingIDCallback& callback) : render_process_id_(render_process_id), resource_context_(resource_context), partition_(partition), - message_port_message_filter_(message_port_message_filter) { + next_routing_id_(callback) { // Note: This constructor is called on both IO or UI thread. DCHECK(resource_context); } @@ -30,6 +30,7 @@ WorkerMessageFilter::~WorkerMessageFilter() { } void WorkerMessageFilter::OnChannelClosing() { + MessagePortService::GetInstance()->OnWorkerMessageFilterClosing(this); WorkerServiceImpl::GetInstance()->OnWorkerMessageFilterClosing(this); } @@ -45,6 +46,24 @@ bool WorkerMessageFilter::OnMessageReceived(const IPC::Message& message, IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToWorker, OnForwardToWorker) // Only sent from renderer. IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentDetached, OnDocumentDetached) + // Message Port related messages. + IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_CreateMessagePort, + OnCreateMessagePort) + IPC_MESSAGE_FORWARD(WorkerProcessHostMsg_DestroyMessagePort, + MessagePortService::GetInstance(), + MessagePortService::Destroy) + IPC_MESSAGE_FORWARD(WorkerProcessHostMsg_Entangle, + MessagePortService::GetInstance(), + MessagePortService::Entangle) + IPC_MESSAGE_FORWARD(WorkerProcessHostMsg_PostMessage, + MessagePortService::GetInstance(), + MessagePortService::PostMessage) + IPC_MESSAGE_FORWARD(WorkerProcessHostMsg_QueueMessages, + MessagePortService::GetInstance(), + MessagePortService::QueueMessages) + IPC_MESSAGE_FORWARD(WorkerProcessHostMsg_SendQueuedMessages, + MessagePortService::GetInstance(), + MessagePortService::SendQueuedMessages) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() @@ -52,14 +71,14 @@ bool WorkerMessageFilter::OnMessageReceived(const IPC::Message& message, } int WorkerMessageFilter::GetNextRoutingID() { - return message_port_message_filter_->GetNextRoutingID(); + return next_routing_id_.Run(); } void WorkerMessageFilter::OnCreateWorker( const ViewHostMsg_CreateWorker_Params& params, int* route_id) { *route_id = params.route_id != MSG_ROUTING_NONE ? - params.route_id : GetNextRoutingID(); + params.route_id : next_routing_id_.Run(); WorkerServiceImpl::GetInstance()->CreateWorker( params, *route_id, this, resource_context_, partition_); } @@ -69,7 +88,7 @@ void WorkerMessageFilter::OnLookupSharedWorker( bool* exists, int* route_id, bool* url_error) { - *route_id = GetNextRoutingID(); + *route_id = next_routing_id_.Run(); WorkerServiceImpl::GetInstance()->LookupSharedWorker( params, *route_id, this, resource_context_, partition_, exists, @@ -84,4 +103,10 @@ void WorkerMessageFilter::OnDocumentDetached(unsigned long long document_id) { WorkerServiceImpl::GetInstance()->DocumentDetached(document_id, this); } +void WorkerMessageFilter::OnCreateMessagePort(int *route_id, + int* message_port_id) { + *route_id = next_routing_id_.Run(); + MessagePortService::GetInstance()->Create(*route_id, this, message_port_id); +} + } // namespace content diff --git a/content/browser/worker_host/worker_message_filter.h b/content/browser/worker_host/worker_message_filter.h index 0d495fa..47f96ef 100644 --- a/content/browser/worker_host/worker_message_filter.h +++ b/content/browser/worker_host/worker_message_filter.h @@ -13,15 +13,18 @@ class ResourceDispatcherHost; struct ViewHostMsg_CreateWorker_Params; namespace content { -class MessagePortMessageFilter; class ResourceContext; class WorkerMessageFilter : public BrowserMessageFilter { public: + typedef base::Callback<int(void)> NextRoutingIDCallback; + + // |next_routing_id| is owned by this object. It can be used up until + // OnChannelClosing. WorkerMessageFilter(int render_process_id, ResourceContext* resource_context, const WorkerStoragePartition& partition, - MessagePortMessageFilter* message_port_filter); + const NextRoutingIDCallback& callback); // BrowserMessageFilter implementation. virtual void OnChannelClosing() OVERRIDE; @@ -31,10 +34,6 @@ class WorkerMessageFilter : public BrowserMessageFilter { int GetNextRoutingID(); int render_process_id() const { return render_process_id_; } - MessagePortMessageFilter* message_port_message_filter() const { - return message_port_message_filter_; - } - private: virtual ~WorkerMessageFilter(); @@ -53,7 +52,10 @@ class WorkerMessageFilter : public BrowserMessageFilter { ResourceContext* const resource_context_; WorkerStoragePartition partition_; - MessagePortMessageFilter* message_port_message_filter_; + // This is guaranteed to be valid until OnChannelClosing is closed, and it's + // not used after. + NextRoutingIDCallback next_routing_id_; + DISALLOW_IMPLICIT_CONSTRUCTORS(WorkerMessageFilter); }; diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc index b132767..f0324d7 100644 --- a/content/browser/worker_host/worker_process_host.cc +++ b/content/browser/worker_host/worker_process_host.cc @@ -25,8 +25,6 @@ #include "content/browser/fileapi/fileapi_message_filter.h" #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" #include "content/browser/loader/resource_message_filter.h" -#include "content/browser/message_port_message_filter.h" -#include "content/browser/message_port_service.h" #include "content/browser/mime_registry_message_filter.h" #include "content/browser/quota_dispatcher_host.h" #include "content/browser/renderer_host/database_message_filter.h" @@ -35,6 +33,7 @@ #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/socket_stream_dispatcher_host.h" #include "content/browser/resource_context_impl.h" +#include "content/browser/worker_host/message_port_service.h" #include "content/browser/worker_host/worker_message_filter.h" #include "content/browser/worker_host/worker_service_impl.h" #include "content/common/child_process_host_impl.h" @@ -224,15 +223,10 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) { get_contexts_callback); process_->AddFilter(resource_message_filter); - MessagePortMessageFilter* message_port_message_filter = - new MessagePortMessageFilter( - base::Bind(&WorkerServiceImpl::next_worker_route_id, - base::Unretained(WorkerServiceImpl::GetInstance()))); - process_->AddFilter(message_port_message_filter); - worker_message_filter_ = new WorkerMessageFilter(render_process_id, - resource_context_, - partition_, - message_port_message_filter); + worker_message_filter_ = new WorkerMessageFilter( + render_process_id, resource_context_, partition_, + base::Bind(&WorkerServiceImpl::next_worker_route_id, + base::Unretained(WorkerServiceImpl::GetInstance()))); process_->AddFilter(worker_message_filter_.get()); process_->AddFilter(new AppCacheDispatcherHost( partition_.appcache_service(), process_->GetData().id)); @@ -406,9 +400,7 @@ void WorkerProcessHost::RelayMessage( } new_routing_id = filter->GetNextRoutingID(); MessagePortService::GetInstance()->UpdateMessagePort( - sent_message_port_id, - filter->message_port_message_filter(), - new_routing_id); + sent_message_port_id, filter, new_routing_id); // Resend the message with the new routing id. filter->Send(new WorkerMsg_Connect( diff --git a/content/child/webmessageportchannel_impl.cc b/content/child/webmessageportchannel_impl.cc index de8866f..ed621ad 100644 --- a/content/child/webmessageportchannel_impl.cc +++ b/content/child/webmessageportchannel_impl.cc @@ -8,7 +8,7 @@ #include "base/message_loop/message_loop_proxy.h" #include "content/child/child_process.h" #include "content/child/child_thread.h" -#include "content/common/message_port_messages.h" +#include "content/common/worker_messages.h" #include "third_party/WebKit/public/platform/WebMessagePortChannelClient.h" #include "third_party/WebKit/public/platform/WebString.h" @@ -53,7 +53,7 @@ WebMessagePortChannelImpl::~WebMessagePortChannelImpl() { } if (message_port_id_ != MSG_ROUTING_NONE) - Send(new MessagePortHostMsg_DestroyMessagePort(message_port_id_)); + Send(new WorkerProcessHostMsg_DestroyMessagePort(message_port_id_)); if (route_id_ != MSG_ROUTING_NONE) ChildThread::current()->RemoveRoute(route_id_); @@ -106,7 +106,7 @@ void WebMessagePortChannelImpl::postMessage( delete channels; } - IPC::Message* msg = new MessagePortHostMsg_PostMessage( + IPC::Message* msg = new WorkerProcessHostMsg_PostMessage( message_port_id_, message, message_port_ids); Send(msg); } @@ -140,7 +140,7 @@ void WebMessagePortChannelImpl::Init() { if (route_id_ == MSG_ROUTING_NONE) { DCHECK(message_port_id_ == MSG_ROUTING_NONE); - Send(new MessagePortHostMsg_CreateMessagePort( + Send(new WorkerProcessHostMsg_CreateMessagePort( &route_id_, &message_port_id_)); } @@ -156,7 +156,7 @@ void WebMessagePortChannelImpl::Entangle( return; } - Send(new MessagePortHostMsg_Entangle( + Send(new WorkerProcessHostMsg_Entangle( message_port_id_, channel->message_port_id())); } @@ -172,7 +172,7 @@ void WebMessagePortChannelImpl::QueueMessages() { // sends us an ack, whose receipt we know means that no more messages are // in-flight. We then send the queued messages to the browser, which prepends // them to the ones it queued and it sends them to the new endpoint. - Send(new MessagePortHostMsg_QueueMessages(message_port_id_)); + Send(new WorkerProcessHostMsg_QueueMessages(message_port_id_)); // The process could potentially go away while we're still waiting for // in-flight messages. Ensure it stays alive. @@ -194,8 +194,8 @@ void WebMessagePortChannelImpl::Send(IPC::Message* message) { bool WebMessagePortChannelImpl::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(WebMessagePortChannelImpl, message) - IPC_MESSAGE_HANDLER(MessagePortMsg_Message, OnMessage) - IPC_MESSAGE_HANDLER(MessagePortMsg_MessagesQueued, OnMessagesQueued) + IPC_MESSAGE_HANDLER(WorkerProcessMsg_Message, OnMessage) + IPC_MESSAGE_HANDLER(WorkerProcessMsg_MessagesQueued, OnMessagesQueued) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -243,7 +243,7 @@ void WebMessagePortChannelImpl::OnMessagesQueued() { } } - Send(new MessagePortHostMsg_SendQueuedMessages( + Send(new WorkerProcessHostMsg_SendQueuedMessages( message_port_id_, queued_messages)); message_port_id_ = MSG_ROUTING_NONE; diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h index 78e7c53..d85d4eb 100644 --- a/content/common/content_message_generator.h +++ b/content/common/content_message_generator.h @@ -40,7 +40,6 @@ #include "content/common/media/video_capture_messages.h" #include "content/common/media/webrtc_identity_messages.h" #include "content/common/memory_benchmark_messages.h" -#include "content/common/message_port_messages.h" #include "content/common/mime_registry_messages.h" #include "content/common/p2p_messages.h" #include "content/common/pepper_messages.h" diff --git a/content/common/message_port_messages.h b/content/common/message_port_messages.h deleted file mode 100644 index 67b729d..0000000 --- a/content/common/message_port_messages.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Defines messages between the browser and worker process, as well as between -// the renderer and worker process. - -// Multiply-included message file, hence no include guard. - -#include <string> -#include <utility> -#include <vector> - -#include "base/basictypes.h" -#include "base/strings/string16.h" -#include "content/common/content_export.h" -#include "ipc/ipc_message_macros.h" -#include "ipc/ipc_message_utils.h" - -#undef IPC_MESSAGE_EXPORT -#define IPC_MESSAGE_EXPORT CONTENT_EXPORT -#define IPC_MESSAGE_START MessagePortMsgStart - -// Singly-included section, not converted. -#ifndef CONTENT_COMMON_MESSAGE_PORT_MESSAGES_H_ -#define CONTENT_COMMON_MESSAGE_PORT_MESSAGES_H_ - -typedef std::pair<string16, std::vector<int> > QueuedMessage; - -#endif // CONTENT_COMMON_MESSAGE_PORT_MESSAGES_H_ - -//----------------------------------------------------------------------------- -// MessagePort messages -// These are messages sent from the browser to child processes. - -// Sends a message to a message port. -IPC_MESSAGE_ROUTED3(MessagePortMsg_Message, - string16 /* message */, - std::vector<int> /* sent_message_port_ids */, - std::vector<int> /* new_routing_ids */) - -// Tells the Message Port Channel object that there are no more in-flight -// messages arriving. -IPC_MESSAGE_ROUTED0(MessagePortMsg_MessagesQueued) - -//----------------------------------------------------------------------------- -// MessagePortHost messages -// These are messages sent from child processes to the browser. - -// Creates a new Message Port Channel object. The first paramaeter is the -// message port channel's routing id in this process. The second parameter -// is the process-wide-unique identifier for that port. -IPC_SYNC_MESSAGE_CONTROL0_2(MessagePortHostMsg_CreateMessagePort, - int /* route_id */, - int /* message_port_id */) - -// Sent when a Message Port Channel object is destroyed. -IPC_MESSAGE_CONTROL1(MessagePortHostMsg_DestroyMessagePort, - int /* message_port_id */) - -// Sends a message to a message port. Optionally sends a message port as -// as well if sent_message_port_id != MSG_ROUTING_NONE. -IPC_MESSAGE_CONTROL3(MessagePortHostMsg_PostMessage, - int /* sender_message_port_id */, - string16 /* message */, - std::vector<int> /* sent_message_port_ids */) - -// Causes messages sent to the remote port to be delivered to this local port. -IPC_MESSAGE_CONTROL2(MessagePortHostMsg_Entangle, - int /* local_message_port_id */, - int /* remote_message_port_id */) - -// Causes the browser to queue messages sent to this port until the the port -// has made sure that all in-flight messages were routed to the new -// destination. -IPC_MESSAGE_CONTROL1(MessagePortHostMsg_QueueMessages, - int /* message_port_id */) - -// Sends the browser all the queued messages that arrived at this message port -// after it was sent in a postMessage call. -// NOTE: MSVS can't compile the macro if std::vector<std::pair<string16, int> > -// is used, so we typedef it in worker_messages.h. -IPC_MESSAGE_CONTROL2(MessagePortHostMsg_SendQueuedMessages, - int /* message_port_id */, - std::vector<QueuedMessage> /* queued_messages */) diff --git a/content/common/worker_messages.h b/content/common/worker_messages.h index d66e456..3f32862 100644 --- a/content/common/worker_messages.h +++ b/content/common/worker_messages.h @@ -19,6 +19,14 @@ #include "third_party/WebKit/public/web/WebContentSecurityPolicy.h" #include "url/gurl.h" +// Singly-included section, not converted. +#ifndef CONTENT_COMMON_WORKER_MESSAGES_H_ +#define CONTENT_COMMON_WORKER_MESSAGES_H_ + +typedef std::pair<string16, std::vector<int> > QueuedMessage; + +#endif // CONTENT_COMMON_WORKER_MESSAGES_H_ + #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START WorkerMsgStart @@ -53,10 +61,64 @@ IPC_ENUM_TRAITS(WebKit::WebContentSecurityPolicyType) IPC_MESSAGE_CONTROL1(WorkerProcessMsg_CreateWorker, WorkerProcessMsg_CreateWorker_Params) +// Note: these Message Port related messages can also be sent to the +// renderer process. Putting them here since we don't have a shared place +// like common_messages_internal.h +IPC_MESSAGE_ROUTED3(WorkerProcessMsg_Message, + string16 /* message */, + std::vector<int> /* sent_message_port_ids */, + std::vector<int> /* new_routing_ids */) + +// Tells the Message Port Channel object that there are no more in-flight +// messages arriving. +IPC_MESSAGE_ROUTED0(WorkerProcessMsg_MessagesQueued) + + //----------------------------------------------------------------------------- // WorkerProcessHost messages // These are messages sent from the worker process to the browser process. +// Note: these Message Port related messages can also be sent out from the +// renderer process. Putting them here since we don't have a shared place +// like common_messages_internal.h + +// Creates a new Message Port Channel object. The first paramaeter is the +// message port channel's routing id in this process. The second parameter +// is the process-wide-unique identifier for that port. +IPC_SYNC_MESSAGE_CONTROL0_2(WorkerProcessHostMsg_CreateMessagePort, + int /* route_id */, + int /* message_port_id */) + +// Sent when a Message Port Channel object is destroyed. +IPC_MESSAGE_CONTROL1(WorkerProcessHostMsg_DestroyMessagePort, + int /* message_port_id */) + +// Sends a message to a message port. Optionally sends a message port as +// as well if sent_message_port_id != MSG_ROUTING_NONE. +IPC_MESSAGE_CONTROL3(WorkerProcessHostMsg_PostMessage, + int /* sender_message_port_id */, + string16 /* message */, + std::vector<int> /* sent_message_port_ids */) + +// Causes messages sent to the remote port to be delivered to this local port. +IPC_MESSAGE_CONTROL2(WorkerProcessHostMsg_Entangle, + int /* local_message_port_id */, + int /* remote_message_port_id */) + +// Causes the browser to queue messages sent to this port until the the port +// has made sure that all in-flight messages were routed to the new +// destination. +IPC_MESSAGE_CONTROL1(WorkerProcessHostMsg_QueueMessages, + int /* message_port_id */) + +// Sends the browser all the queued messages that arrived at this message port +// after it was sent in a postMessage call. +// NOTE: MSVS can't compile the macro if std::vector<std::pair<string16, int> > +// is used, so we typedef it in worker_messages.h. +IPC_MESSAGE_CONTROL2(WorkerProcessHostMsg_SendQueuedMessages, + int /* message_port_id */, + std::vector<QueuedMessage> /* queued_messages */) + // Sent by the worker process to check whether access to web databases is // allowed. IPC_SYNC_MESSAGE_CONTROL5_1(WorkerProcessHostMsg_AllowDatabase, diff --git a/content/content_browser.gypi b/content/content_browser.gypi index dffcb74..38e92d6 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -721,10 +721,6 @@ 'browser/media/webrtc_internals_ui.h', 'browser/media/webrtc_internals_ui_observer.h', 'browser/media_devices_monitor.cc', - 'browser/message_port_message_filter.cc', - 'browser/message_port_message_filter.h', - 'browser/message_port_service.cc', - 'browser/message_port_service.h', 'browser/mime_registry_message_filter.cc', 'browser/mime_registry_message_filter.h', 'browser/service_worker/service_worker_dispatcher_host.h', @@ -1213,6 +1209,8 @@ 'browser/webui/web_ui_impl.cc', 'browser/webui/web_ui_impl.h', 'browser/webui/web_ui_message_handler.cc', + 'browser/worker_host/message_port_service.cc', + 'browser/worker_host/message_port_service.h', 'browser/worker_host/worker_document_set.cc', 'browser/worker_host/worker_document_set.h', 'browser/worker_host/worker_message_filter.cc', diff --git a/content/content_common.gypi b/content/content_common.gypi index cb3b2c5..9c70800 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -295,7 +295,6 @@ 'common/media/video_capture_messages.h', 'common/media/webrtc_identity_messages.h', 'common/memory_benchmark_messages.h', - 'common/message_port_messages.h', 'common/message_router.cc', 'common/message_router.h', 'common/mime_registry_messages.h', diff --git a/ipc/ipc_message_start.h b/ipc/ipc_message_start.h index 7ce2bdd..e71755f 100644 --- a/ipc/ipc_message_start.h +++ b/ipc/ipc_message_start.h @@ -91,7 +91,6 @@ enum IPCMessageStart { PowerMonitorMsgStart, EncryptedMediaMsgStart, ServiceWorkerMsgStart, - MessagePortMsgStart, LastIPCMsgStart // Must come last. }; |