OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * be 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 const uint32_t kMaxVarSize = 64 * 1024; |
17 | 17 |
18 // Serialize one PP_Var to the location given in "bytes", using no more | 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 | 19 // than "*length" bytes . If successful, "*length" reflects the number of |
20 // bytes written and true is returned. Otherwise returns false. | 20 // bytes written and true is returned. Otherwise returns false. |
21 bool SerializeTo(const PP_Var* var, char* bytes, uint32_t* length); | 21 bool SerializeTo(const PP_Var* var, char* bytes, uint32_t* length); |
22 | 22 |
23 // Serialize a vector of "argc" PP_Vars to a buffer to be allocated by new[]. | 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 | 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. | 25 // to the number of bytes allocated. Otherwise, NULL is returned. |
26 char* Serialize(const PP_Var* vars, uint32_t argc, uint32_t* length); | 26 char* Serialize(const PP_Var* vars, uint32_t argc, uint32_t* length); |
27 | 27 |
28 // Deserialize a vector "bytes" of "length" bytes containing "argc" PP_Vars | 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 | 29 // into the vector of PP_Vars pointed to by "vars". Returns true if |
30 // successful, or false otherwise. | 30 // successful, or false otherwise. |
31 bool DeserializeTo(NaClSrpcChannel* channel, | 31 bool DeserializeTo(char* bytes, |
32 char* bytes, | |
33 uint32_t length, | 32 uint32_t length, |
34 uint32_t argc, | 33 uint32_t argc, |
35 PP_Var* vars); | 34 PP_Var* vars); |
36 | 35 |
37 } // namespace ppapi_proxy | 36 } // namespace ppapi_proxy |
38 | 37 |
39 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_OBJECT_SERIALIZE_H_ | 38 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_OBJECT_SERIALIZE_H_ |
OLD | NEW |