OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file provides infrastructure for dispatching messasges from host | 5 // This file provides infrastructure for dispatching messasges from host |
6 // resource, inlcuding reply messages or unsolicited replies. Normal IPC Reply | 6 // resource, inlcuding reply messages or unsolicited replies. Normal IPC Reply |
7 // handlers can't take extra parameters. We want to take a | 7 // handlers can't take extra parameters. We want to take a |
8 // ResourceMessageReplyParams as a parameter. | 8 // ResourceMessageReplyParams as a parameter. |
9 | 9 |
10 #ifndef PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ | 10 #ifndef PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 void DispatchResourceReplyOrDefaultParams( | 122 void DispatchResourceReplyOrDefaultParams( |
123 base::Callback<void(const ResourceMessageReplyParams&)>* obj, | 123 base::Callback<void(const ResourceMessageReplyParams&)>* obj, |
124 Method method, | 124 Method method, |
125 const ResourceMessageReplyParams& reply_params, | 125 const ResourceMessageReplyParams& reply_params, |
126 const IPC::Message& msg) { | 126 const IPC::Message& msg) { |
127 DCHECK(msg.type() == MsgClass::ID || msg.type() == 0) | 127 DCHECK(msg.type() == MsgClass::ID || msg.type() == 0) |
128 << "Resource reply message of unexpected type."; | 128 << "Resource reply message of unexpected type."; |
129 (obj->*method)(reply_params); | 129 (obj->*method)(reply_params); |
130 } | 130 } |
131 | 131 |
132 #define PPAPI_BEGIN_MESSAGE_MAP(class_name, msg) \ | |
brettw
2014/05/13 21:55:33
Can you add a comment about why we need a differen
jam
2014/05/13 21:59:56
Done.
| |
133 { \ | |
134 typedef class_name _IpcMessageHandlerClass; \ | |
135 const IPC::Message& ipc_message__ = msg; \ | |
136 switch (ipc_message__.type()) { \ | |
137 | |
132 // Note that this only works for message with 1 or more parameters. For | 138 // Note that this only works for message with 1 or more parameters. For |
133 // 0-parameter messages you need to use the _0 version below (since there are | 139 // 0-parameter messages you need to use the _0 version below (since there are |
134 // no params in the message). | 140 // no params in the message). |
135 #define PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(msg_class, member_func) \ | 141 #define PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(msg_class, member_func) \ |
136 case msg_class::ID: { \ | 142 case msg_class::ID: { \ |
137 msg_class::Schema::Param p; \ | 143 msg_class::Schema::Param p; \ |
138 if (msg_class::Read(&ipc_message__, &p)) { \ | 144 if (msg_class::Read(&ipc_message__, &p)) { \ |
139 ppapi::proxy::DispatchResourceReply( \ | 145 ppapi::proxy::DispatchResourceReply( \ |
140 this, \ | 146 this, \ |
141 &_IpcMessageHandlerClass::member_func, \ | 147 &_IpcMessageHandlerClass::member_func, \ |
142 params, p); \ | 148 params, p); \ |
143 } else { \ | 149 } else { \ |
144 NOTREACHED(); \ | 150 NOTREACHED(); \ |
145 } \ | 151 } \ |
146 break; \ | 152 break; \ |
147 } | 153 } |
148 | 154 |
149 #define PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_0(msg_class, member_func) \ | 155 #define PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_0(msg_class, member_func) \ |
150 case msg_class::ID: { \ | 156 case msg_class::ID: { \ |
151 member_func(params); \ | 157 member_func(params); \ |
152 break; \ | 158 break; \ |
153 } | 159 } |
154 | 160 |
155 #define PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(code) \ | 161 #define PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(code) \ |
156 default: { \ | 162 default: { \ |
157 code; \ | 163 code; \ |
158 } \ | 164 } \ |
159 break; | 165 break; |
160 | 166 |
167 #define PPAPI_END_MESSAGE_MAP() \ | |
168 } \ | |
169 } | |
170 | |
161 } // namespace proxy | 171 } // namespace proxy |
162 } // namespace ppapi | 172 } // namespace ppapi |
163 | 173 |
164 #endif // PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ | 174 #endif // PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_ |
OLD | NEW |