diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-24 06:19:28 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-24 06:19:28 +0000 |
commit | a95986a837fc86e079b5c6dac357636478b50092 (patch) | |
tree | 66a32009250791e64741216cdd6c21ecf1ff7f86 /chrome/plugin | |
parent | 125a7ba65ad10ace9edcf36d6943ce9ae2bdc1d6 (diff) | |
download | chromium_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/plugin')
-rw-r--r-- | chrome/plugin/command_buffer_stub.cc | 7 | ||||
-rw-r--r-- | chrome/plugin/command_buffer_stub.h | 2 | ||||
-rw-r--r-- | chrome/plugin/npobject_proxy.cc | 3 | ||||
-rw-r--r-- | chrome/plugin/npobject_proxy.h | 2 | ||||
-rw-r--r-- | chrome/plugin/npobject_stub.cc | 9 | ||||
-rw-r--r-- | chrome/plugin/npobject_stub.h | 2 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel.cc | 11 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel.h | 4 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel_base.cc | 13 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel_base.h | 4 | ||||
-rw-r--r-- | chrome/plugin/plugin_thread.cc | 5 | ||||
-rw-r--r-- | chrome/plugin/plugin_thread.h | 2 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.cc | 8 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.h | 2 |
14 files changed, 47 insertions, 27 deletions
diff --git a/chrome/plugin/command_buffer_stub.cc b/chrome/plugin/command_buffer_stub.cc index 5818414..de9bbdb 100644 --- a/chrome/plugin/command_buffer_stub.cc +++ b/chrome/plugin/command_buffer_stub.cc @@ -27,7 +27,8 @@ CommandBufferStub::~CommandBufferStub() { channel_->RemoveRoute(route_id_); } -void CommandBufferStub::OnMessageReceived(const IPC::Message& message) { +bool CommandBufferStub::OnMessageReceived(const IPC::Message& message) { + bool handled = true; IPC_BEGIN_MESSAGE_MAP(CommandBufferStub, message) IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Initialize, OnInitialize); IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetState, OnGetState); @@ -43,8 +44,10 @@ void CommandBufferStub::OnMessageReceived(const IPC::Message& message) { #if defined(OS_MACOSX) IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetWindowSize, OnSetWindowSize); #endif - IPC_MESSAGE_UNHANDLED_ERROR() + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() + DCHECK(handled); + return handled; } void CommandBufferStub::OnChannelError() { diff --git a/chrome/plugin/command_buffer_stub.h b/chrome/plugin/command_buffer_stub.h index 7519659..e9f65c6 100644 --- a/chrome/plugin/command_buffer_stub.h +++ b/chrome/plugin/command_buffer_stub.h @@ -31,7 +31,7 @@ class CommandBufferStub : public IPC::Channel::Listener, virtual ~CommandBufferStub(); // IPC::Channel::Listener implementation: - virtual void OnMessageReceived(const IPC::Message& message); + virtual bool OnMessageReceived(const IPC::Message& message); virtual void OnChannelError(); // IPC::Message::Sender implementation: diff --git a/chrome/plugin/npobject_proxy.cc b/chrome/plugin/npobject_proxy.cc index 0b7ff45..8a429fb 100644 --- a/chrome/plugin/npobject_proxy.cc +++ b/chrome/plugin/npobject_proxy.cc @@ -104,8 +104,9 @@ void NPObjectProxy::NPDeallocate(NPObject* npObj) { delete obj; } -void NPObjectProxy::OnMessageReceived(const IPC::Message& msg) { +bool NPObjectProxy::OnMessageReceived(const IPC::Message& msg) { NOTREACHED(); + return false; } void NPObjectProxy::OnChannelError() { diff --git a/chrome/plugin/npobject_proxy.h b/chrome/plugin/npobject_proxy.h index 6b6e7ff..4b6b595 100644 --- a/chrome/plugin/npobject_proxy.h +++ b/chrome/plugin/npobject_proxy.h @@ -102,7 +102,7 @@ class NPObjectProxy : public IPC::Channel::Listener, const GURL& page_url); // IPC::Channel::Listener implementation: - virtual void OnMessageReceived(const IPC::Message& msg); + virtual bool OnMessageReceived(const IPC::Message& msg); virtual void OnChannelError(); static NPObject* NPAllocate(NPP, NPClass*); diff --git a/chrome/plugin/npobject_stub.cc b/chrome/plugin/npobject_stub.cc index e0a8436..7fd18dd 100644 --- a/chrome/plugin/npobject_stub.cc +++ b/chrome/plugin/npobject_stub.cc @@ -62,7 +62,7 @@ IPC::Channel::Listener* NPObjectStub::GetChannelListener() { return static_cast<IPC::Channel::Listener*>(this); } -void NPObjectStub::OnMessageReceived(const IPC::Message& msg) { +bool NPObjectStub::OnMessageReceived(const IPC::Message& msg) { child_process_logging::SetActiveURL(page_url_); if (!npobject_) { @@ -74,9 +74,10 @@ void NPObjectStub::OnMessageReceived(const IPC::Message& msg) { Send(reply); } - return; + return true; } + bool handled = true; IPC_BEGIN_MESSAGE_MAP(NPObjectStub, msg) IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Release, OnRelease); IPC_MESSAGE_HANDLER(NPObjectMsg_HasMethod, OnHasMethod); @@ -89,8 +90,10 @@ void NPObjectStub::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(NPObjectMsg_Enumeration, OnEnumeration); IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Construct, OnConstruct); IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Evaluate, OnEvaluate); - IPC_MESSAGE_UNHANDLED_ERROR() + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() + DCHECK(handled); + return handled; } void NPObjectStub::OnChannelError() { diff --git a/chrome/plugin/npobject_stub.h b/chrome/plugin/npobject_stub.h index 248d001..d43fbad 100644 --- a/chrome/plugin/npobject_stub.h +++ b/chrome/plugin/npobject_stub.h @@ -53,7 +53,7 @@ class NPObjectStub : public IPC::Channel::Listener, private: // IPC::Channel::Listener implementation: - virtual void OnMessageReceived(const IPC::Message& message); + virtual bool OnMessageReceived(const IPC::Message& message); virtual void OnChannelError(); // message handlers diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc index bc5e61e..fc789353 100644 --- a/chrome/plugin/plugin_channel.cc +++ b/chrome/plugin/plugin_channel.cc @@ -190,23 +190,26 @@ bool PluginChannel::Send(IPC::Message* msg) { return result; } -void PluginChannel::OnMessageReceived(const IPC::Message& msg) { +bool PluginChannel::OnMessageReceived(const IPC::Message& msg) { if (log_messages_) { VLOG(1) << "received message @" << &msg << " on channel @" << this << " with type " << msg.type(); } - PluginChannelBase::OnMessageReceived(msg); + return PluginChannelBase::OnMessageReceived(msg); } -void PluginChannel::OnControlMessageReceived(const IPC::Message& msg) { +bool PluginChannel::OnControlMessageReceived(const IPC::Message& msg) { + bool handled = true; IPC_BEGIN_MESSAGE_MAP(PluginChannel, msg) IPC_MESSAGE_HANDLER(PluginMsg_CreateInstance, OnCreateInstance) IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginMsg_DestroyInstance, OnDestroyInstance) IPC_MESSAGE_HANDLER(PluginMsg_GenerateRouteID, OnGenerateRouteID) IPC_MESSAGE_HANDLER(PluginMsg_ClearSiteData, OnClearSiteData) - IPC_MESSAGE_UNHANDLED_ERROR() + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() + DCHECK(handled); + return handled; } void PluginChannel::OnCreateInstance(const std::string& mime_type, diff --git a/chrome/plugin/plugin_channel.h b/chrome/plugin/plugin_channel.h index 519e03c..102d4d6 100644 --- a/chrome/plugin/plugin_channel.h +++ b/chrome/plugin/plugin_channel.h @@ -33,7 +33,7 @@ class PluginChannel : public PluginChannelBase { virtual ~PluginChannel(); virtual bool Send(IPC::Message* msg); - virtual void OnMessageReceived(const IPC::Message& message); + virtual bool OnMessageReceived(const IPC::Message& message); base::ProcessHandle renderer_handle() const { return renderer_handle_; } int renderer_id() { return renderer_id_; } @@ -69,7 +69,7 @@ class PluginChannel : public PluginChannelBase { // Called on the plugin thread PluginChannel(); - virtual void OnControlMessageReceived(const IPC::Message& msg); + virtual bool OnControlMessageReceived(const IPC::Message& msg); static PluginChannelBase* ClassFactory() { return new PluginChannel(); } diff --git a/chrome/plugin/plugin_channel_base.cc b/chrome/plugin/plugin_channel_base.cc index 37bc1c4..e251e9e 100644 --- a/chrome/plugin/plugin_channel_base.cc +++ b/chrome/plugin/plugin_channel_base.cc @@ -140,19 +140,20 @@ int PluginChannelBase::Count() { return static_cast<int>(g_plugin_channels_.size()); } -void PluginChannelBase::OnMessageReceived(const IPC::Message& message) { +bool PluginChannelBase::OnMessageReceived(const IPC::Message& message) { // This call might cause us to be deleted, so keep an extra reference to // ourself so that we can send the reply and decrement back in_dispatch_. lazy_plugin_channel_stack_.Pointer()->push( scoped_refptr<PluginChannelBase>(this)); + bool handled; if (message.should_unblock()) in_unblock_dispatch_++; if (message.routing_id() == MSG_ROUTING_CONTROL) { - OnControlMessageReceived(message); + handled = OnControlMessageReceived(message); } else { - bool routed = router_.RouteMessage(message); - if (!routed && message.is_sync()) { + handled = router_.RouteMessage(message); + if (!handled && message.is_sync()) { // The listener has gone away, so we must respond or else the caller will // hang waiting for a reply. IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message); @@ -164,6 +165,7 @@ void PluginChannelBase::OnMessageReceived(const IPC::Message& message) { in_unblock_dispatch_--; lazy_plugin_channel_stack_.Pointer()->pop(); + return handled; } void PluginChannelBase::OnChannelConnected(int32 peer_pid) { @@ -228,9 +230,10 @@ void PluginChannelBase::RemoveRoute(int route_id) { } } -void PluginChannelBase::OnControlMessageReceived(const IPC::Message& msg) { +bool PluginChannelBase::OnControlMessageReceived(const IPC::Message& msg) { NOTREACHED() << "should override in subclass if you care about control messages"; + return false; } void PluginChannelBase::OnChannelError() { diff --git a/chrome/plugin/plugin_channel_base.h b/chrome/plugin/plugin_channel_base.h index 22103e8..d1a1a1c 100644 --- a/chrome/plugin/plugin_channel_base.h +++ b/chrome/plugin/plugin_channel_base.h @@ -89,10 +89,10 @@ class PluginChannelBase : public IPC::Channel::Listener, virtual void CleanUp() { } // Implemented by derived classes 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); virtual void OnChannelConnected(int32 peer_pid); virtual void OnChannelError(); diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index 8edcbbd..d5757e1 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -128,13 +128,16 @@ PluginThread* PluginThread::current() { return lazy_tls.Pointer()->Get(); } -void PluginThread::OnControlMessageReceived(const IPC::Message& msg) { +bool PluginThread::OnControlMessageReceived(const IPC::Message& msg) { + bool handled = true; IPC_BEGIN_MESSAGE_MAP(PluginThread, msg) IPC_MESSAGE_HANDLER(PluginProcessMsg_CreateChannel, OnCreateChannel) IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginMessage, OnPluginMessage) IPC_MESSAGE_HANDLER(PluginProcessMsg_NotifyRenderersOfPendingShutdown, OnNotifyRenderersOfPendingShutdown) + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() + return handled; } void PluginThread::OnCreateChannel(int renderer_id, diff --git a/chrome/plugin/plugin_thread.h b/chrome/plugin/plugin_thread.h index 4d24e3c..f5ef267 100644 --- a/chrome/plugin/plugin_thread.h +++ b/chrome/plugin/plugin_thread.h @@ -31,7 +31,7 @@ class PluginThread : public ChildThread { FilePath plugin_path() { return plugin_path_; } private: - virtual void OnControlMessageReceived(const IPC::Message& msg); + virtual bool OnControlMessageReceived(const IPC::Message& msg); // Callback for when a channel has been created. void OnCreateChannel(int renderer_id, bool off_the_record); diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index 0540adf..41b0256 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -88,7 +88,7 @@ WebPluginDelegateStub::~WebPluginDelegateStub() { } } -void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { +bool WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { child_process_logging::SetActiveURL(page_url_); // A plugin can execute a script to delete itself in any of its NPP methods. @@ -98,6 +98,7 @@ void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { if (!in_destructor_) AddRef(); + bool handled = true; IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) IPC_MESSAGE_HANDLER(PluginMsg_Init, OnInit) IPC_MESSAGE_HANDLER(PluginMsg_WillSendRequest, OnWillSendRequest) @@ -146,11 +147,14 @@ void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(PluginMsg_SetFakeAcceleratedSurfaceWindowHandle, OnSetFakeAcceleratedSurfaceWindowHandle) #endif - IPC_MESSAGE_UNHANDLED_ERROR() + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() if (!in_destructor_) Release(); + + DCHECK(handled); + return handled; } bool WebPluginDelegateStub::Send(IPC::Message* msg) { diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index c310467..0a95587 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -45,7 +45,7 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, PluginChannel* channel); // IPC::Channel::Listener implementation: - virtual void OnMessageReceived(const IPC::Message& msg); + virtual bool OnMessageReceived(const IPC::Message& msg); // IPC::Message::Sender implementation: virtual bool Send(IPC::Message* msg); |