summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-24 06:19:28 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-24 06:19:28 +0000
commita95986a837fc86e079b5c6dac357636478b50092 (patch)
tree66a32009250791e64741216cdd6c21ecf1ff7f86 /chrome/common
parent125a7ba65ad10ace9edcf36d6943ce9ae2bdc1d6 (diff)
downloadchromium_src-a95986a837fc86e079b5c6dac357636478b50092.zip
chromium_src-a95986a837fc86e079b5c6dac357636478b50092.tar.gz
chromium_src-a95986a837fc86e079b5c6dac357636478b50092.tar.bz2
Make IPC::Channel::Listener:OnMessageReceived have a return value indicating whether a message was processed or not.
TBR=brettw Review URL: http://codereview.chromium.org/5978003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/appcache/appcache_dispatcher.h5
-rw-r--r--chrome/common/child_process_host.cc7
-rw-r--r--chrome/common/child_process_host.h4
-rw-r--r--chrome/common/child_thread.cc19
-rw-r--r--chrome/common/child_thread.h6
-rw-r--r--chrome/common/file_system/file_system_dispatcher.h3
-rw-r--r--chrome/common/message_router.cc14
-rw-r--r--chrome/common/message_router.h4
-rw-r--r--chrome/common/resource_dispatcher.h5
-rw-r--r--chrome/common/socket_stream_dispatcher.h9
-rw-r--r--chrome/common/webmessageportchannel_impl.cc5
-rw-r--r--chrome/common/webmessageportchannel_impl.h2
12 files changed, 44 insertions, 39 deletions
diff --git a/chrome/common/appcache/appcache_dispatcher.h b/chrome/common/appcache/appcache_dispatcher.h
index f099183..f88a38a 100644
--- a/chrome/common/appcache/appcache_dispatcher.h
+++ b/chrome/common/appcache/appcache_dispatcher.h
@@ -9,20 +9,21 @@
#include <string>
#include <vector>
#include "chrome/common/appcache/appcache_backend_proxy.h"
-#include "ipc/ipc_message.h"
+#include "ipc/ipc_channel.h"
#include "webkit/appcache/appcache_frontend_impl.h"
// Dispatches appcache related messages sent to a child process from the
// main browser process. There is one instance per child process. Messages
// are dispatched on the main child thread. The ChildThread base class
// creates an instance and delegates calls to it.
-class AppCacheDispatcher {
+class AppCacheDispatcher : public IPC::Channel::Listener {
public:
explicit AppCacheDispatcher(IPC::Message::Sender* sender)
: backend_proxy_(sender) {}
AppCacheBackendProxy* backend_proxy() { return &backend_proxy_; }
+ // IPC::Channel::Listener implementation
bool OnMessageReceived(const IPC::Message& msg);
private:
diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc
index c19d0ca..e03b3a6 100644
--- a/chrome/common/child_process_host.cc
+++ b/chrome/common/child_process_host.cc
@@ -155,13 +155,13 @@ ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host)
: host_(host) {
}
-void ChildProcessHost::ListenerHook::OnMessageReceived(
+bool ChildProcessHost::ListenerHook::OnMessageReceived(
const IPC::Message& msg) {
#ifdef IPC_MESSAGE_LOG_ENABLED
IPC::Logging* logger = IPC::Logging::GetInstance();
if (msg.type() == IPC_LOGGING_ID) {
logger->OnReceivedLoggingMessage(msg);
- return;
+ return true;
}
if (logger->Enabled())
@@ -183,12 +183,13 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
}
if (!handled)
- host_->OnMessageReceived(msg);
+ handled = host_->OnMessageReceived(msg);
#ifdef IPC_MESSAGE_LOG_ENABLED
if (logger->Enabled())
logger->OnPostDispatchMessage(msg, host_->channel_id_);
#endif
+ return handled;
}
void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) {
diff --git a/chrome/common/child_process_host.h b/chrome/common/child_process_host.h
index 3b467ec..c822346 100644
--- a/chrome/common/child_process_host.h
+++ b/chrome/common/child_process_host.h
@@ -80,7 +80,7 @@ class ChildProcessHost : public IPC::Channel::Listener,
virtual void InstanceCreated();
// IPC::Channel::Listener implementation:
- virtual void OnMessageReceived(const IPC::Message& msg) { }
+ virtual bool OnMessageReceived(const IPC::Message& msg) { return false; }
virtual void OnChannelConnected(int32 peer_pid) { }
virtual void OnChannelError() { }
@@ -102,7 +102,7 @@ class ChildProcessHost : public IPC::Channel::Listener,
class ListenerHook : public IPC::Channel::Listener {
public:
explicit ListenerHook(ChildProcessHost* host);
- virtual void OnMessageReceived(const IPC::Message& msg);
+ virtual bool OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelConnected(int32 peer_pid);
virtual void OnChannelError();
private:
diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc
index 2a46de8..53823bc 100644
--- a/chrome/common/child_thread.cc
+++ b/chrome/common/child_thread.cc
@@ -139,14 +139,14 @@ MessageLoop* ChildThread::message_loop() {
return message_loop_;
}
-void ChildThread::OnMessageReceived(const IPC::Message& msg) {
+bool ChildThread::OnMessageReceived(const IPC::Message& msg) {
// Resource responses are sent to the resource dispatcher.
if (resource_dispatcher_->OnMessageReceived(msg))
- return;
+ return true;
if (socket_stream_dispatcher_->OnMessageReceived(msg))
- return;
+ return true;
if (file_system_dispatcher_->OnMessageReceived(msg))
- return;
+ return true;
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ChildThread, msg)
@@ -160,13 +160,12 @@ void ChildThread::OnMessageReceived(const IPC::Message& msg) {
IPC_END_MESSAGE_MAP()
if (handled)
- return;
+ return true;
- if (msg.routing_id() == MSG_ROUTING_CONTROL) {
- OnControlMessageReceived(msg);
- } else {
- router_.OnMessageReceived(msg);
- }
+ if (msg.routing_id() == MSG_ROUTING_CONTROL)
+ return OnControlMessageReceived(msg);
+
+ return router_.OnMessageReceived(msg);
}
void ChildThread::OnAskBeforeShutdown() {
diff --git a/chrome/common/child_thread.h b/chrome/common/child_thread.h
index 337a7f8..dbe8677 100644
--- a/chrome/common/child_thread.h
+++ b/chrome/common/child_thread.h
@@ -74,7 +74,9 @@ class ChildThread : public IPC::Channel::Listener,
// Called when the process refcount is 0.
void OnProcessFinalRelease();
- virtual void OnControlMessageReceived(const IPC::Message& msg) { }
+ virtual bool OnControlMessageReceived(const IPC::Message& msg) {
+ return false;
+ }
virtual void OnAskBeforeShutdown();
virtual void OnShutdown();
@@ -92,7 +94,7 @@ class ChildThread : public IPC::Channel::Listener,
void Init();
// IPC::Channel::Listener implementation:
- virtual void OnMessageReceived(const IPC::Message& msg);
+ virtual bool OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelError();
std::string channel_name_;
diff --git a/chrome/common/file_system/file_system_dispatcher.h b/chrome/common/file_system/file_system_dispatcher.h
index b8ffb2c..21bc792 100644
--- a/chrome/common/file_system/file_system_dispatcher.h
+++ b/chrome/common/file_system/file_system_dispatcher.h
@@ -25,11 +25,12 @@ class GURL;
// Dispatches and sends file system related messages sent to/from a child
// process from/to the main browser process. There is one instance
// per child process. Messages are dispatched on the main child thread.
-class FileSystemDispatcher {
+class FileSystemDispatcher : public IPC::Channel::Listener {
public:
FileSystemDispatcher();
~FileSystemDispatcher();
+ // IPC::Channel::Listener implementation.
bool OnMessageReceived(const IPC::Message& msg);
bool OpenFileSystem(const GURL& origin_url,
diff --git a/chrome/common/message_router.cc b/chrome/common/message_router.cc
index 6bd6e95..b3ea5960 100644
--- a/chrome/common/message_router.cc
+++ b/chrome/common/message_router.cc
@@ -10,9 +10,10 @@ MessageRouter::MessageRouter() {
MessageRouter::~MessageRouter() {
}
-void MessageRouter::OnControlMessageReceived(const IPC::Message& msg) {
+bool MessageRouter::OnControlMessageReceived(const IPC::Message& msg) {
NOTREACHED() <<
"should override in subclass if you care about control messages";
+ return false;
}
bool MessageRouter::Send(IPC::Message* msg) {
@@ -30,12 +31,11 @@ void MessageRouter::RemoveRoute(int32 routing_id) {
routes_.Remove(routing_id);
}
-void MessageRouter::OnMessageReceived(const IPC::Message& msg) {
- if (msg.routing_id() == MSG_ROUTING_CONTROL) {
- OnControlMessageReceived(msg);
- } else {
- RouteMessage(msg);
- }
+bool MessageRouter::OnMessageReceived(const IPC::Message& msg) {
+ if (msg.routing_id() == MSG_ROUTING_CONTROL)
+ return OnControlMessageReceived(msg);
+
+ return RouteMessage(msg);
}
bool MessageRouter::RouteMessage(const IPC::Message& msg) {
diff --git a/chrome/common/message_router.h b/chrome/common/message_router.h
index 6a61091..e6709be 100644
--- a/chrome/common/message_router.h
+++ b/chrome/common/message_router.h
@@ -34,10 +34,10 @@ class MessageRouter : public IPC::Channel::Listener,
virtual ~MessageRouter();
// Implemented by subclasses to handle control messages
- virtual void OnControlMessageReceived(const IPC::Message& msg);
+ virtual bool OnControlMessageReceived(const IPC::Message& msg);
// IPC::Channel::Listener implementation:
- virtual void OnMessageReceived(const IPC::Message& msg);
+ virtual bool OnMessageReceived(const IPC::Message& msg);
// Like OnMessageReceived, except it only handles routed messages. Returns
// true if the message was dispatched, or false if there was no listener for
diff --git a/chrome/common/resource_dispatcher.h b/chrome/common/resource_dispatcher.h
index 3ca3492..52c6589 100644
--- a/chrome/common/resource_dispatcher.h
+++ b/chrome/common/resource_dispatcher.h
@@ -23,13 +23,12 @@ struct ResourceResponseHead;
// This class serves as a communication interface between the
// ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in
// the child process. It can be used from any child process.
-class ResourceDispatcher {
+class ResourceDispatcher : public IPC::Channel::Listener {
public:
explicit ResourceDispatcher(IPC::Message::Sender* sender);
~ResourceDispatcher();
- // Called to possibly handle the incoming IPC message. Returns true if
- // handled, else false.
+ // IPC::Channel::Listener implementation.
bool OnMessageReceived(const IPC::Message& message);
// Creates a ResourceLoaderBridge for this type of dispatcher, this is so
diff --git a/chrome/common/socket_stream_dispatcher.h b/chrome/common/socket_stream_dispatcher.h
index e0bf58f..01c5421 100644
--- a/chrome/common/socket_stream_dispatcher.h
+++ b/chrome/common/socket_stream_dispatcher.h
@@ -9,10 +9,7 @@
#include <vector>
#include "base/basictypes.h"
-
-namespace IPC {
-class Message;
-}
+#include "ipc/ipc_channel.h"
namespace WebKit {
class WebSocketStreamHandle;
@@ -27,7 +24,7 @@ class WebSocketStreamHandleDelegate;
// main browser process. There is one instance per child process. Messages
// are dispatched on the main child thread. The RenderThread class
// creates an instance of SocketStreamDispatcher and delegates calls to it.
-class SocketStreamDispatcher {
+class SocketStreamDispatcher : public IPC::Channel::Listener {
public:
SocketStreamDispatcher();
~SocketStreamDispatcher() {}
@@ -35,6 +32,8 @@ class SocketStreamDispatcher {
static webkit_glue::WebSocketStreamHandleBridge* CreateBridge(
WebKit::WebSocketStreamHandle* handle,
webkit_glue::WebSocketStreamHandleDelegate* delegate);
+
+ // IPC::Channel::Listener implementation.
bool OnMessageReceived(const IPC::Message& msg);
private:
diff --git a/chrome/common/webmessageportchannel_impl.cc b/chrome/common/webmessageportchannel_impl.cc
index b7a9388..0778871 100644
--- a/chrome/common/webmessageportchannel_impl.cc
+++ b/chrome/common/webmessageportchannel_impl.cc
@@ -180,11 +180,14 @@ void WebMessagePortChannelImpl::Send(IPC::Message* message) {
ChildThread::current()->Send(message);
}
-void WebMessagePortChannelImpl::OnMessageReceived(const IPC::Message& message) {
+bool WebMessagePortChannelImpl::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebMessagePortChannelImpl, message)
IPC_MESSAGE_HANDLER(WorkerProcessMsg_Message, OnMessage)
IPC_MESSAGE_HANDLER(WorkerProcessMsg_MessagesQueued, OnMessagedQueued)
+ IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
+ return handled;
}
void WebMessagePortChannelImpl::OnMessage(
diff --git a/chrome/common/webmessageportchannel_impl.h b/chrome/common/webmessageportchannel_impl.h
index 3c96fc38..0199ebb 100644
--- a/chrome/common/webmessageportchannel_impl.h
+++ b/chrome/common/webmessageportchannel_impl.h
@@ -48,7 +48,7 @@ class WebMessagePortChannelImpl
void Send(IPC::Message* message);
// IPC::Channel::Listener implementation.
- virtual void OnMessageReceived(const IPC::Message& message);
+ virtual bool OnMessageReceived(const IPC::Message& message);
void OnMessage(const string16& message,
const std::vector<int>& sent_message_port_ids,