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