Skip to content
Snippets Groups Projects
Commit a95986a8 authored by jam@chromium.org's avatar jam@chromium.org
Browse files

Make IPC::Channel::Listener:OnMessageReceived have a return value indicating...

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
parent 125a7ba6
No related merge requests found
Showing
with 78 additions and 53 deletions
......@@ -60,20 +60,19 @@ void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) {
bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, message, *message_was_ok)
IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost);
IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost);
IPC_MESSAGE_HANDLER(AppCacheMsg_GetResourceList, OnGetResourceList);
IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCache, OnSelectCache);
IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost)
IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost)
IPC_MESSAGE_HANDLER(AppCacheMsg_GetResourceList, OnGetResourceList)
IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCache, OnSelectCache)
IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForWorker,
OnSelectCacheForWorker);
OnSelectCacheForWorker)
IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCacheForSharedWorker,
OnSelectCacheForSharedWorker);
IPC_MESSAGE_HANDLER(AppCacheMsg_MarkAsForeignEntry, OnMarkAsForeignEntry);
IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_GetStatus, OnGetStatus);
IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_StartUpdate, OnStartUpdate);
IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_SwapCache, OnSwapCache);
OnSelectCacheForSharedWorker)
IPC_MESSAGE_HANDLER(AppCacheMsg_MarkAsForeignEntry, OnMarkAsForeignEntry)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_GetStatus, OnGetStatus)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_StartUpdate, OnStartUpdate)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_SwapCache, OnSwapCache)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
......
......@@ -358,14 +358,15 @@ void AutomationProvider::OnChannelConnected(int pid) {
Send(new AutomationMsg_InitialLoadsComplete());
}
void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
bool AutomationProvider::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AutomationProvider, message)
#if !defined(OS_MACOSX)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag,
WindowSimulateDrag)
#endif // !defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(AutomationMsg_HandleUnused, HandleUnused)
IPC_MESSAGE_HANDLER(AutomationMsg_SetProxyConfig, SetProxyConfig);
IPC_MESSAGE_HANDLER(AutomationMsg_SetProxyConfig, SetProxyConfig)
IPC_MESSAGE_HANDLER(AutomationMsg_PrintAsync, PrintAsync)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Find, HandleFindRequest)
IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding)
......@@ -429,8 +430,9 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_LoginWithUserAndPass,
LoginWithUserAndPass)
#endif // defined(OS_CHROMEOS)
IPC_MESSAGE_UNHANDLED(OnUnhandledMessage())
IPC_MESSAGE_UNHANDLED(handled = false;OnUnhandledMessage())
IPC_END_MESSAGE_MAP()
return handled;
}
void AutomationProvider::OnUnhandledMessage() {
......
......@@ -148,7 +148,7 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
// IPC implementations
virtual bool Send(IPC::Message* msg);
virtual void OnChannelConnected(int pid);
virtual void OnMessageReceived(const IPC::Message& msg);
virtual bool OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelError();
IPC::Message* reply_message_release() {
......
......@@ -12,13 +12,13 @@
ChromeFrameAutomationProvider::ChromeFrameAutomationProvider(Profile* profile)
: AutomationProvider(profile) {}
void ChromeFrameAutomationProvider::OnMessageReceived(
bool ChromeFrameAutomationProvider::OnMessageReceived(
const IPC::Message& message) {
if (IsValidMessage(message.type())) {
AutomationProvider::OnMessageReceived(message);
} else {
OnUnhandledMessage(message);
}
if (IsValidMessage(message.type()))
return AutomationProvider::OnMessageReceived(message);
OnUnhandledMessage(message);
return false;
}
void ChromeFrameAutomationProvider::OnUnhandledMessage(
......
......@@ -24,7 +24,7 @@ class ChromeFrameAutomationProvider : public AutomationProvider {
explicit ChromeFrameAutomationProvider(Profile* profile);
// IPC::Channel::Listener overrides.
virtual void OnMessageReceived(const IPC::Message& message);
virtual bool OnMessageReceived(const IPC::Message& message);
protected:
// This function is called when we receive an invalid message type.
......
......@@ -203,8 +203,9 @@ void TestingAutomationProvider::Observe(NotificationType type,
Release();
}
void TestingAutomationProvider::OnMessageReceived(
bool TestingAutomationProvider::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(TestingAutomationProvider, message)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseBrowser, CloseBrowser)
IPC_MESSAGE_HANDLER(AutomationMsg_CloseBrowserRequestAsync,
......@@ -389,8 +390,10 @@ void TestingAutomationProvider::OnMessageReceived(
IPC_MESSAGE_HANDLER(AutomationMsg_LoadBlockedPlugins, LoadBlockedPlugins)
IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme)
IPC_MESSAGE_UNHANDLED(AutomationProvider::OnMessageReceived(message));
IPC_MESSAGE_UNHANDLED(
handled = AutomationProvider::OnMessageReceived(message))
IPC_END_MESSAGE_MAP()
return handled;
}
void TestingAutomationProvider::OnChannelError() {
......
......@@ -33,7 +33,7 @@ class TestingAutomationProvider : public AutomationProvider,
virtual void OnBrowserRemoved(const Browser* browser);
// IPC::Channel::Listener implementation.
virtual void OnMessageReceived(const IPC::Message& msg);
virtual bool OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelError();
private:
......
......@@ -132,13 +132,14 @@ bool GpuProcessHost::Send(IPC::Message* msg) {
return BrowserChildProcessHost::Send(msg);
}
void GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread());
if (message.routing_id() == MSG_ROUTING_CONTROL)
OnControlMessageReceived(message);
else
RouteOnUIThread(message);
return OnControlMessageReceived(message);
RouteOnUIThread(message);
return true;
}
void GpuProcessHost::EstablishGpuChannel(int renderer_id,
......@@ -178,7 +179,7 @@ GpuProcessHost::SynchronizationRequest::SynchronizationRequest(
GpuProcessHost::SynchronizationRequest::~SynchronizationRequest() {}
void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) {
bool GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread());
IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message)
......@@ -202,6 +203,8 @@ void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) {
// handle it.
IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message))
IPC_END_MESSAGE_MAP()
return true;
}
void GpuProcessHost::OnChannelEstablished(
......
......@@ -37,7 +37,7 @@ class GpuProcessHost : public BrowserChildProcessHost, public NonThreadSafe {
virtual bool Send(IPC::Message* msg);
// IPC::Channel::Listener implementation.
virtual void OnMessageReceived(const IPC::Message& message);
virtual bool OnMessageReceived(const IPC::Message& message);
// Tells the GPU process to create a new channel for communication with a
// renderer. Will asynchronously send message to object with given routing id
......@@ -77,7 +77,7 @@ class GpuProcessHost : public BrowserChildProcessHost, public NonThreadSafe {
bool EnsureInitialized();
bool Init();
void OnControlMessageReceived(const IPC::Message& message);
bool OnControlMessageReceived(const IPC::Message& message);
// Message handlers.
void OnChannelEstablished(const IPC::ChannelHandle& channel_handle,
......
......@@ -63,13 +63,13 @@ void GpuProcessHostUIShim::RemoveRoute(int32 routing_id) {
router_.RemoveRoute(routing_id);
}
void GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) {
bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread());
if (message.routing_id() == MSG_ROUTING_CONTROL)
OnControlMessageReceived(message);
else
router_.RouteMessage(message);
return OnControlMessageReceived(message);
return router_.RouteMessage(message);
}
void GpuProcessHostUIShim::CollectGraphicsInfoAsynchronously() {
......@@ -119,7 +119,8 @@ void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id,
}
host->ScheduleComposite();
}
void GpuProcessHostUIShim::OnControlMessageReceived(
bool GpuProcessHostUIShim::OnControlMessageReceived(
const IPC::Message& message) {
DCHECK(CalledOnValidThread());
......@@ -127,9 +128,10 @@ void GpuProcessHostUIShim::OnControlMessageReceived(
IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected,
OnGraphicsInfoCollected)
#if defined(OS_WIN)
IPC_MESSAGE_HANDLER(GpuHostMsg_ScheduleComposite,
OnScheduleComposite);
IPC_MESSAGE_HANDLER(GpuHostMsg_ScheduleComposite, OnScheduleComposite);
#endif
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
return true;
}
......@@ -36,7 +36,7 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender,
// The GpuProcessHost causes this to be called on the UI thread to
// dispatch the incoming messages from the GPU process, which are
// actually received on the IO thread.
virtual void OnMessageReceived(const IPC::Message& message);
virtual bool OnMessageReceived(const IPC::Message& message);
// See documentation on MessageRouter for AddRoute and RemoveRoute
void AddRoute(int32 routing_id, IPC::Channel::Listener* listener);
......@@ -72,7 +72,7 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender,
// Message handlers.
void OnGraphicsInfoCollected(const GPUInfo& gpu_info);
void OnScheduleComposite(int32 renderer_id, int32 render_view_id);
void OnControlMessageReceived(const IPC::Message& message);
bool OnControlMessageReceived(const IPC::Message& message);
int last_routing_id_;
......
......@@ -94,11 +94,14 @@ class FFDecryptorServerChannelListener : public IPC::Channel::Listener {
sender_->Send(new Msg_Decryptor_Quit());
}
virtual void OnMessageReceived(const IPC::Message& msg) {
virtual bool OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(FFDecryptorServerChannelListener, msg)
IPC_MESSAGE_HANDLER(Msg_Decryptor_InitReturnCode, OnInitDecryptorResponse)
IPC_MESSAGE_HANDLER(Msg_Decryptor_Response, OnDecryptedTextResonse)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
// If an error occured, just kill the message Loop.
......@@ -231,12 +234,15 @@ class FFDecryptorClientChannelListener : public IPC::Channel::Listener {
MessageLoop::current()->Quit();
}
virtual void OnMessageReceived(const IPC::Message& msg) {
virtual bool OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(FFDecryptorClientChannelListener, msg)
IPC_MESSAGE_HANDLER(Msg_Decryptor_Init, OnDecryptor_Init)
IPC_MESSAGE_HANDLER(Msg_Decrypt, OnDecrypt)
IPC_MESSAGE_HANDLER(Msg_Decryptor_Quit, OnQuitRequest)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
virtual void OnChannelError() {
......
......@@ -46,10 +46,13 @@ bool NaClBrokerHost::Init() {
return true;
}
void NaClBrokerHost::OnMessageReceived(const IPC::Message& msg) {
bool NaClBrokerHost::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(NaClBrokerHost, msg)
IPC_MESSAGE_HANDLER(NaClProcessMsg_LoaderLaunched, OnLoaderLaunched)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
bool NaClBrokerHost::LaunchLoader(
......
......@@ -33,7 +33,7 @@ class NaClBrokerHost : public BrowserChildProcessHost {
base::ProcessHandle handle);
// IPC::Channel::Listener
virtual void OnMessageReceived(const IPC::Message& msg);
virtual bool OnMessageReceived(const IPC::Message& msg);
bool stopping_;
......
......@@ -282,8 +282,9 @@ void NaClProcessHost::SendStartMessage() {
sockets_for_sel_ldr_.clear();
}
void NaClProcessHost::OnMessageReceived(const IPC::Message& msg) {
bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) {
NOTREACHED() << "Invalid message with type = " << msg.type();
return false;
}
bool NaClProcessHost::CanShutdown() {
......
......@@ -32,7 +32,7 @@ class NaClProcessHost : public BrowserChildProcessHost {
int socket_count,
IPC::Message* reply_msg);
virtual void OnMessageReceived(const IPC::Message& msg);
virtual bool OnMessageReceived(const IPC::Message& msg);
void OnProcessLaunchedByBroker(base::ProcessHandle handle);
......
......@@ -115,12 +115,14 @@ void PluginDataRemover::OnTimeout() {
SignalDone();
}
void PluginDataRemover::OnMessageReceived(const IPC::Message& msg) {
bool PluginDataRemover::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(PluginDataRemover, msg)
IPC_MESSAGE_HANDLER(PluginHostMsg_ClearSiteDataResult,
OnClearSiteDataResult)
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
return true;
}
void PluginDataRemover::OnChannelError() {
......
......@@ -45,8 +45,8 @@ class PluginDataRemover : public base::RefCountedThreadSafe<PluginDataRemover>,
virtual void OnChannelOpened(const IPC::ChannelHandle& handle);
virtual void OnError();
// IPC::ChannelProxy::MessageFilter methods
virtual void OnMessageReceived(const IPC::Message& message);
// IPC::Channel::Listener methods
virtual bool OnMessageReceived(const IPC::Message& message);
virtual void OnChannelError();
private:
......
......@@ -298,7 +298,8 @@ void PluginProcessHost::OnProcessLaunched() {
}
}
void PluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PluginProcessHost, msg)
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated)
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_GetPluginFinderUrl,
......@@ -327,8 +328,11 @@ void PluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginSetCursorVisibility,
OnPluginSetCursorVisibility)
#endif
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
DCHECK(handled);
return handled;
}
void PluginProcessHost::OnChannelConnected(int32 peer_pid) {
......
......@@ -66,7 +66,7 @@ class PluginProcessHost : public BrowserChildProcessHost,
// Force the plugin process to shutdown (cleanly).
virtual void ForceShutdown();
virtual void OnMessageReceived(const IPC::Message& msg);
virtual bool OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelConnected(int32 peer_pid);
virtual void OnChannelError();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment