summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_message.h
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-13 23:19:10 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-13 23:19:10 +0000
commit5636d90f630655abf66427e30d15f615dc939797 (patch)
tree434691134b27d5f98aaff57635b05bcdba98e1b7 /ipc/ipc_message.h
parent07243f95c726fb67abefa8a19fb9c46e2d63d8f8 (diff)
downloadchromium_src-5636d90f630655abf66427e30d15f615dc939797.zip
chromium_src-5636d90f630655abf66427e30d15f615dc939797.tar.gz
chromium_src-5636d90f630655abf66427e30d15f615dc939797.tar.bz2
Add support for passing an arbitrary parameter to an IPC message handler. The motivation is for WebContentsObserver to pass RenderFrameHost* to message handlers easily.
As an example, an observer would look like this: bool FooWebContentsObserver::OnMessageReceived( const IPC::Message& message, RenderFrameHost* render_frame_host) { IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(FooWebContentsObserver, message, RenderFrameHost, render_frame_host) IPC_MESSAGE_HANDLER(FooHostMsg_Bar, OnBar) . . . void FooWebContentsObserver::OnBar(RenderFrameHost* render_frame_host, ... You can of course still have dispatchers without the extra parameter as before. This is generalizing the existing code that allows an IPC message handler to have a "const IPC::Message& message) first parameter to get access to the IPC. Sync IPCs don't support this yet. It's a lot more work because for them we conveniently reuse tuple's DispatchToMethod. This isn't urgent yet, since sync IPCs aren't dispatched on the UI thread for the most part because of NPAPI and Windows, so punting on this for now. BUG=304341 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/283623002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270237 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_message.h')
-rw-r--r--ipc/ipc_message.h26
1 files changed, 6 insertions, 20 deletions
diff --git a/ipc/ipc_message.h b/ipc/ipc_message.h
index 1b13d67..ea6cda6 100644
--- a/ipc/ipc_message.h
+++ b/ipc/ipc_message.h
@@ -141,31 +141,17 @@ class IPC_EXPORT Message : public Pickle {
// call.
void SetHeaderValues(int32 routing, uint32 type, uint32 flags);
- template<class T, class S>
- static bool Dispatch(const Message* msg, T* obj, S* sender,
+ template<class T, class S, class P>
+ static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter,
void (T::*func)()) {
(obj->*func)();
return true;
}
- template<class T, class S>
- static bool Dispatch(const Message* msg, T* obj, S* sender,
- void (T::*func)() const) {
- (obj->*func)();
- return true;
- }
-
- template<class T, class S>
- static bool Dispatch(const Message* msg, T* obj, S* sender,
- void (T::*func)(const Message&)) {
- (obj->*func)(*msg);
- return true;
- }
-
- template<class T, class S>
- static bool Dispatch(const Message* msg, T* obj, S* sender,
- void (T::*func)(const Message&) const) {
- (obj->*func)(*msg);
+ template<class T, class S, class P>
+ static bool Dispatch(const Message* msg, T* obj, S* sender, P* parameter,
+ void (T::*func)(P*)) {
+ (obj->*func)(parameter);
return true;
}