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