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 #ifndef PPAPI_PROXY_PLUGIN_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_PLUGIN_RESOURCE_H_ |
6 #define PPAPI_PROXY_PLUGIN_RESOURCE_H_ | 6 #define PPAPI_PROXY_PLUGIN_RESOURCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 int32_t SyncCall(Destination dest, const IPC::Message& msg, A* a, B* b); | 117 int32_t SyncCall(Destination dest, const IPC::Message& msg, A* a, B* b); |
118 template <class ReplyMsgClass, class A, class B, class C> | 118 template <class ReplyMsgClass, class A, class B, class C> |
119 int32_t SyncCall(Destination dest, const IPC::Message& msg, A* a, B* b, C* c); | 119 int32_t SyncCall(Destination dest, const IPC::Message& msg, A* a, B* b, C* c); |
120 template <class ReplyMsgClass, class A, class B, class C, class D> | 120 template <class ReplyMsgClass, class A, class B, class C, class D> |
121 int32_t SyncCall( | 121 int32_t SyncCall( |
122 Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d); | 122 Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d); |
123 template <class ReplyMsgClass, class A, class B, class C, class D, class E> | 123 template <class ReplyMsgClass, class A, class B, class C, class D, class E> |
124 int32_t SyncCall( | 124 int32_t SyncCall( |
125 Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e); | 125 Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e); |
126 | 126 |
| 127 int32_t GenericSyncCall(Destination dest, |
| 128 const IPC::Message& msg, |
| 129 IPC::Message* reply_msg, |
| 130 ResourceMessageReplyParams* reply_params); |
| 131 |
127 private: | 132 private: |
128 // Helper function to send a |PpapiHostMsg_ResourceCall| to the given | 133 // Helper function to send a |PpapiHostMsg_ResourceCall| to the given |
129 // destination with |nested_msg| and |call_params|. | 134 // destination with |nested_msg| and |call_params|. |
130 bool SendResourceCall(Destination dest, | 135 bool SendResourceCall(Destination dest, |
131 const ResourceMessageCallParams& call_params, | 136 const ResourceMessageCallParams& call_params, |
132 const IPC::Message& nested_msg); | 137 const IPC::Message& nested_msg); |
133 | 138 |
134 int32_t GenericSyncCall(Destination dest, | |
135 const IPC::Message& msg, | |
136 IPC::Message* reply_msg); | |
137 | |
138 int32_t GetNextSequence(); | 139 int32_t GetNextSequence(); |
139 | 140 |
140 Connection connection_; | 141 Connection connection_; |
141 | 142 |
142 // Use GetNextSequence to retrieve the next value. | 143 // Use GetNextSequence to retrieve the next value. |
143 int32_t next_sequence_number_; | 144 int32_t next_sequence_number_; |
144 | 145 |
145 bool sent_create_to_browser_; | 146 bool sent_create_to_browser_; |
146 bool sent_create_to_renderer_; | 147 bool sent_create_to_renderer_; |
147 | 148 |
(...skipping 15 matching lines...) Expand all Loading... |
163 new PluginResourceCallback<ReplyMsgClass, CallbackType>(callback)); | 164 new PluginResourceCallback<ReplyMsgClass, CallbackType>(callback)); |
164 callbacks_.insert(std::make_pair(params.sequence(), plugin_callback)); | 165 callbacks_.insert(std::make_pair(params.sequence(), plugin_callback)); |
165 params.set_has_callback(); | 166 params.set_has_callback(); |
166 SendResourceCall(dest, params, msg); | 167 SendResourceCall(dest, params, msg); |
167 return params.sequence(); | 168 return params.sequence(); |
168 } | 169 } |
169 | 170 |
170 template <class ReplyMsgClass> | 171 template <class ReplyMsgClass> |
171 int32_t PluginResource::SyncCall(Destination dest, const IPC::Message& msg) { | 172 int32_t PluginResource::SyncCall(Destination dest, const IPC::Message& msg) { |
172 IPC::Message reply; | 173 IPC::Message reply; |
173 return GenericSyncCall(dest, msg, &reply); | 174 ResourceMessageReplyParams reply_params; |
| 175 return GenericSyncCall(dest, msg, &reply, &reply_params); |
174 } | 176 } |
175 | 177 |
176 template <class ReplyMsgClass, class A> | 178 template <class ReplyMsgClass, class A> |
177 int32_t PluginResource::SyncCall( | 179 int32_t PluginResource::SyncCall( |
178 Destination dest, const IPC::Message& msg, A* a) { | 180 Destination dest, const IPC::Message& msg, A* a) { |
179 IPC::Message reply; | 181 IPC::Message reply; |
180 int32_t result = GenericSyncCall(dest, msg, &reply); | 182 ResourceMessageReplyParams reply_params; |
| 183 int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); |
181 | 184 |
182 if (UnpackMessage<ReplyMsgClass>(reply, a)) | 185 if (UnpackMessage<ReplyMsgClass>(reply, a)) |
183 return result; | 186 return result; |
184 return PP_ERROR_FAILED; | 187 return PP_ERROR_FAILED; |
185 } | 188 } |
186 | 189 |
187 template <class ReplyMsgClass, class A, class B> | 190 template <class ReplyMsgClass, class A, class B> |
188 int32_t PluginResource::SyncCall( | 191 int32_t PluginResource::SyncCall( |
189 Destination dest, const IPC::Message& msg, A* a, B* b) { | 192 Destination dest, const IPC::Message& msg, A* a, B* b) { |
190 IPC::Message reply; | 193 IPC::Message reply; |
191 int32_t result = GenericSyncCall(dest, msg, &reply); | 194 ResourceMessageReplyParams reply_params; |
| 195 int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); |
192 | 196 |
193 if (UnpackMessage<ReplyMsgClass>(reply, a, b)) | 197 if (UnpackMessage<ReplyMsgClass>(reply, a, b)) |
194 return result; | 198 return result; |
195 return PP_ERROR_FAILED; | 199 return PP_ERROR_FAILED; |
196 } | 200 } |
197 | 201 |
198 template <class ReplyMsgClass, class A, class B, class C> | 202 template <class ReplyMsgClass, class A, class B, class C> |
199 int32_t PluginResource::SyncCall( | 203 int32_t PluginResource::SyncCall( |
200 Destination dest, const IPC::Message& msg, A* a, B* b, C* c) { | 204 Destination dest, const IPC::Message& msg, A* a, B* b, C* c) { |
201 IPC::Message reply; | 205 IPC::Message reply; |
202 int32_t result = GenericSyncCall(dest, msg, &reply); | 206 ResourceMessageReplyParams reply_params; |
| 207 int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); |
203 | 208 |
204 if (UnpackMessage<ReplyMsgClass>(reply, a, b, c)) | 209 if (UnpackMessage<ReplyMsgClass>(reply, a, b, c)) |
205 return result; | 210 return result; |
206 return PP_ERROR_FAILED; | 211 return PP_ERROR_FAILED; |
207 } | 212 } |
208 | 213 |
209 template <class ReplyMsgClass, class A, class B, class C, class D> | 214 template <class ReplyMsgClass, class A, class B, class C, class D> |
210 int32_t PluginResource::SyncCall( | 215 int32_t PluginResource::SyncCall( |
211 Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d) { | 216 Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d) { |
212 IPC::Message reply; | 217 IPC::Message reply; |
213 int32_t result = GenericSyncCall(dest, msg, &reply); | 218 ResourceMessageReplyParams reply_params; |
| 219 int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); |
214 | 220 |
215 if (UnpackMessage<ReplyMsgClass>(reply, a, b, c, d)) | 221 if (UnpackMessage<ReplyMsgClass>(reply, a, b, c, d)) |
216 return result; | 222 return result; |
217 return PP_ERROR_FAILED; | 223 return PP_ERROR_FAILED; |
218 } | 224 } |
219 | 225 |
220 template <class ReplyMsgClass, class A, class B, class C, class D, class E> | 226 template <class ReplyMsgClass, class A, class B, class C, class D, class E> |
221 int32_t PluginResource::SyncCall( | 227 int32_t PluginResource::SyncCall( |
222 Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e) { | 228 Destination dest, const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e) { |
223 IPC::Message reply; | 229 IPC::Message reply; |
224 int32_t result = GenericSyncCall(dest, msg, &reply); | 230 ResourceMessageReplyParams reply_params; |
| 231 int32_t result = GenericSyncCall(dest, msg, &reply, &reply_params); |
225 | 232 |
226 if (UnpackMessage<ReplyMsgClass>(reply, a, b, c, d, e)) | 233 if (UnpackMessage<ReplyMsgClass>(reply, a, b, c, d, e)) |
227 return result; | 234 return result; |
228 return PP_ERROR_FAILED; | 235 return PP_ERROR_FAILED; |
229 } | 236 } |
230 | 237 |
231 } // namespace proxy | 238 } // namespace proxy |
232 } // namespace ppapi | 239 } // namespace ppapi |
233 | 240 |
234 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_ | 241 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_ |
OLD | NEW |