OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2010 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can |
| 4 * be found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_OBJECT_SERIALIZE_H_ |
| 8 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_OBJECT_SERIALIZE_H_ |
| 9 |
| 10 #include "ppapi/c/pp_var.h" |
| 11 |
| 12 struct NaClSrpcChannel; |
| 13 |
| 14 namespace ppapi_proxy { |
| 15 |
| 16 const uint32_t kMaxVarSize = 64 * 1024; |
| 17 |
| 18 // Serialize one PP_Var to the location given in "bytes", using no more |
| 19 // than "*length" bytes . If successful, "*length" reflects the number of |
| 20 // bytes written and true is returned. Otherwise returns false. |
| 21 bool SerializeTo(const PP_Var* var, char* bytes, uint32_t* length); |
| 22 |
| 23 // Serialize a vector of "argc" PP_Vars to a buffer to be allocated by new[]. |
| 24 // If successful, the address of a buffer is returned and "*length" is set |
| 25 // to the number of bytes allocated. Otherwise, NULL is returned. |
| 26 char* Serialize(const PP_Var* vars, uint32_t argc, uint32_t* length); |
| 27 |
| 28 // Deserialize a vector "bytes" of "length" bytes containing "argc" PP_Vars |
| 29 // into the vector of PP_Vars pointed to by "vars". Returns true if |
| 30 // successful, or false otherwise. |
| 31 bool DeserializeTo(NaClSrpcChannel* channel, |
| 32 char* bytes, |
| 33 uint32_t length, |
| 34 uint32_t argc, |
| 35 PP_Var* vars); |
| 36 |
| 37 } // namespace ppapi_proxy |
| 38 |
| 39 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_OBJECT_SERIALIZE_H_ |
OLD | NEW |