| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SERIALIZED_VAR_H_ | 5 #ifndef PPAPI_PROXY_SERIALIZED_VAR_H_ |
| 6 #define PPAPI_PROXY_SERIALIZED_VAR_H_ | 6 #define PPAPI_PROXY_SERIALIZED_VAR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // For sending a value to the remote side. | 177 // For sending a value to the remote side. |
| 178 // | 178 // |
| 179 // Example for API: | 179 // Example for API: |
| 180 // void MyFunction(PP_Var) | 180 // void MyFunction(PP_Var) |
| 181 // IPC message: | 181 // IPC message: |
| 182 // IPC_MESSAGE_ROUTED1(MyFunction, SerializedVar); | 182 // IPC_MESSAGE_ROUTED1(MyFunction, SerializedVar); |
| 183 // Sender would be: | 183 // Sender would be: |
| 184 // void MyFunctionProxy(PP_Var param) { | 184 // void MyFunctionProxy(PP_Var param) { |
| 185 // Send(new MyFunctionMsg(SerializedVarSendInput(dispatcher, param)); | 185 // Send(new MyFunctionMsg(SerializedVarSendInput(dispatcher, param)); |
| 186 // } | 186 // } |
| 187 class SerializedVarSendInput : public SerializedVar { | 187 class PPAPI_PROXY_EXPORT SerializedVarSendInput : public SerializedVar { |
| 188 public: | 188 public: |
| 189 SerializedVarSendInput(Dispatcher* dispatcher, const PP_Var& var); | 189 SerializedVarSendInput(Dispatcher* dispatcher, const PP_Var& var); |
| 190 | 190 |
| 191 // Helper function for serializing a vector of input vars for serialization. | 191 // Helper function for serializing a vector of input vars for serialization. |
| 192 static void ConvertVector(Dispatcher* dispatcher, | 192 static void ConvertVector(Dispatcher* dispatcher, |
| 193 const PP_Var* input, | 193 const PP_Var* input, |
| 194 size_t input_count, | 194 size_t input_count, |
| 195 std::vector<SerializedVar>* output); | 195 std::vector<SerializedVar>* output); |
| 196 | 196 |
| 197 private: | 197 private: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 // Example for API: | 237 // Example for API: |
| 238 // "void MyFunction(PP_Var* exception);" | 238 // "void MyFunction(PP_Var* exception);" |
| 239 // IPC message: | 239 // IPC message: |
| 240 // IPC_SYNC_MESSAGE_ROUTED0_1(MyFunction, SerializedVar); | 240 // IPC_SYNC_MESSAGE_ROUTED0_1(MyFunction, SerializedVar); |
| 241 // Message handler would be: | 241 // Message handler would be: |
| 242 // void OnMsgMyFunction(PP_Var* exception) { | 242 // void OnMsgMyFunction(PP_Var* exception) { |
| 243 // ReceiveSerializedException se(dispatcher(), exception) | 243 // ReceiveSerializedException se(dispatcher(), exception) |
| 244 // Send(new PpapiHostMsg_Foo(&se)); | 244 // Send(new PpapiHostMsg_Foo(&se)); |
| 245 // } | 245 // } |
| 246 class ReceiveSerializedException : public SerializedVar { | 246 class PPAPI_PROXY_EXPORT ReceiveSerializedException : public SerializedVar { |
| 247 public: | 247 public: |
| 248 ReceiveSerializedException(Dispatcher* dispatcher, PP_Var* exception); | 248 ReceiveSerializedException(Dispatcher* dispatcher, PP_Var* exception); |
| 249 ~ReceiveSerializedException(); | 249 ~ReceiveSerializedException(); |
| 250 | 250 |
| 251 // Returns true if the exception passed in the constructor is set. Check | 251 // Returns true if the exception passed in the constructor is set. Check |
| 252 // this before actually issuing the IPC. | 252 // this before actually issuing the IPC. |
| 253 bool IsThrown() const; | 253 bool IsThrown() const; |
| 254 | 254 |
| 255 private: | 255 private: |
| 256 Dispatcher* dispatcher_; | 256 Dispatcher* dispatcher_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 267 // | 267 // |
| 268 // Example for API: | 268 // Example for API: |
| 269 // "void MyFunction(uint32_t* count, PP_Var** vars);" | 269 // "void MyFunction(uint32_t* count, PP_Var** vars);" |
| 270 // IPC message: | 270 // IPC message: |
| 271 // IPC_SYNC_MESSAGE_ROUTED0_1(MyFunction, std::vector<SerializedVar>); | 271 // IPC_SYNC_MESSAGE_ROUTED0_1(MyFunction, std::vector<SerializedVar>); |
| 272 // Proxy function: | 272 // Proxy function: |
| 273 // void MyFunction(uint32_t* count, PP_Var** vars) { | 273 // void MyFunction(uint32_t* count, PP_Var** vars) { |
| 274 // ReceiveSerializedVarVectorOutParam vect(dispatcher, count, vars); | 274 // ReceiveSerializedVarVectorOutParam vect(dispatcher, count, vars); |
| 275 // Send(new MyMsg(vect.OutParam())); | 275 // Send(new MyMsg(vect.OutParam())); |
| 276 // } | 276 // } |
| 277 class ReceiveSerializedVarVectorOutParam { | 277 class PPAPI_PROXY_EXPORT ReceiveSerializedVarVectorOutParam { |
| 278 public: | 278 public: |
| 279 ReceiveSerializedVarVectorOutParam(Dispatcher* dispatcher, | 279 ReceiveSerializedVarVectorOutParam(Dispatcher* dispatcher, |
| 280 uint32_t* output_count, | 280 uint32_t* output_count, |
| 281 PP_Var** output); | 281 PP_Var** output); |
| 282 ~ReceiveSerializedVarVectorOutParam(); | 282 ~ReceiveSerializedVarVectorOutParam(); |
| 283 | 283 |
| 284 std::vector<SerializedVar>* OutParam(); | 284 std::vector<SerializedVar>* OutParam(); |
| 285 | 285 |
| 286 private: | 286 private: |
| 287 Dispatcher* dispatcher_; | 287 Dispatcher* dispatcher_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 }; | 326 }; |
| 327 | 327 |
| 328 // For receiving an input vector of vars from the remote side. | 328 // For receiving an input vector of vars from the remote side. |
| 329 // | 329 // |
| 330 // Example: | 330 // Example: |
| 331 // OnMsgMyFunction(SerializedVarVectorReceiveInput vector) { | 331 // OnMsgMyFunction(SerializedVarVectorReceiveInput vector) { |
| 332 // uint32_t size; | 332 // uint32_t size; |
| 333 // PP_Var* array = vector.Get(dispatcher, &size); | 333 // PP_Var* array = vector.Get(dispatcher, &size); |
| 334 // MyFunction(size, array); | 334 // MyFunction(size, array); |
| 335 // } | 335 // } |
| 336 class SerializedVarVectorReceiveInput { | 336 class PPAPI_PROXY_EXPORT SerializedVarVectorReceiveInput { |
| 337 public: | 337 public: |
| 338 SerializedVarVectorReceiveInput(const std::vector<SerializedVar>& serialized); | 338 SerializedVarVectorReceiveInput(const std::vector<SerializedVar>& serialized); |
| 339 ~SerializedVarVectorReceiveInput(); | 339 ~SerializedVarVectorReceiveInput(); |
| 340 | 340 |
| 341 // Only call Get() once. It will return a pointer to the converted array and | 341 // Only call Get() once. It will return a pointer to the converted array and |
| 342 // place the array size in the out param. Will return NULL when the array is | 342 // place the array size in the out param. Will return NULL when the array is |
| 343 // empty. | 343 // empty. |
| 344 PP_Var* Get(Dispatcher* dispatcher, uint32_t* array_size); | 344 PP_Var* Get(Dispatcher* dispatcher, uint32_t* array_size); |
| 345 | 345 |
| 346 private: | 346 private: |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 // This is the value actually written by the code and returned by OutParam. | 408 // This is the value actually written by the code and returned by OutParam. |
| 409 // We'll write this into serialized_ in our destructor. | 409 // We'll write this into serialized_ in our destructor. |
| 410 PP_Var writable_var_; | 410 PP_Var writable_var_; |
| 411 | 411 |
| 412 Dispatcher* dispatcher_; | 412 Dispatcher* dispatcher_; |
| 413 }; | 413 }; |
| 414 | 414 |
| 415 // For returning an array of PP_Vars to the other side and transferring | 415 // For returning an array of PP_Vars to the other side and transferring |
| 416 // ownership. | 416 // ownership. |
| 417 // | 417 // |
| 418 class SerializedVarVectorOutParam { | 418 class PPAPI_PROXY_EXPORT SerializedVarVectorOutParam { |
| 419 public: | 419 public: |
| 420 SerializedVarVectorOutParam(std::vector<SerializedVar>* serialized); | 420 SerializedVarVectorOutParam(std::vector<SerializedVar>* serialized); |
| 421 ~SerializedVarVectorOutParam(); | 421 ~SerializedVarVectorOutParam(); |
| 422 | 422 |
| 423 uint32_t* CountOutParam() { return &count_; } | 423 uint32_t* CountOutParam() { return &count_; } |
| 424 PP_Var** ArrayOutParam(Dispatcher* dispatcher); | 424 PP_Var** ArrayOutParam(Dispatcher* dispatcher); |
| 425 | 425 |
| 426 private: | 426 private: |
| 427 Dispatcher* dispatcher_; | 427 Dispatcher* dispatcher_; |
| 428 std::vector<SerializedVar>* serialized_; | 428 std::vector<SerializedVar>* serialized_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 454 PP_Var GetIncompleteVar() const { return inner_->GetIncompleteVar(); } | 454 PP_Var GetIncompleteVar() const { return inner_->GetIncompleteVar(); } |
| 455 | 455 |
| 456 const std::string& GetString() const { return inner_->GetString(); } | 456 const std::string& GetString() const { return inner_->GetString(); } |
| 457 }; | 457 }; |
| 458 | 458 |
| 459 } // namespace proxy | 459 } // namespace proxy |
| 460 } // namespace ppapi | 460 } // namespace ppapi |
| 461 | 461 |
| 462 #endif // PPAPI_PROXY_SERIALIZED_VAR_H_ | 462 #endif // PPAPI_PROXY_SERIALIZED_VAR_H_ |
| 463 | 463 |
| OLD | NEW |