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 #include "ppapi/proxy/host_var_serialization_rules.h" | 5 #include "ppapi/proxy/host_var_serialization_rules.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/ppb_var.h" | 8 #include "ppapi/c/ppb_var.h" |
9 | 9 |
10 namespace ppapi { | 10 namespace ppapi { |
(...skipping 15 matching lines...) Expand all Loading... |
26 VarToString(var, str_val); | 26 VarToString(var, str_val); |
27 return var; | 27 return var; |
28 } | 28 } |
29 | 29 |
30 PP_Var HostVarSerializationRules::BeginReceiveCallerOwned( | 30 PP_Var HostVarSerializationRules::BeginReceiveCallerOwned( |
31 const PP_Var& var, | 31 const PP_Var& var, |
32 const std::string* str_val, | 32 const std::string* str_val, |
33 Dispatcher* /* dispatcher */) { | 33 Dispatcher* /* dispatcher */) { |
34 if (var.type == PP_VARTYPE_STRING) { | 34 if (var.type == PP_VARTYPE_STRING) { |
35 // Convert the string to the context of the current process. | 35 // Convert the string to the context of the current process. |
36 return var_interface_->VarFromUtf8(pp_module_, str_val->c_str(), | 36 return var_interface_->VarFromUtf8(str_val->c_str(), |
37 static_cast<uint32_t>(str_val->size())); | 37 static_cast<uint32_t>(str_val->size())); |
38 } | 38 } |
39 return var; | 39 return var; |
40 } | 40 } |
41 | 41 |
42 void HostVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { | 42 void HostVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { |
43 if (var.type == PP_VARTYPE_STRING) { | 43 if (var.type == PP_VARTYPE_STRING) { |
44 // Destroy the string BeginReceiveCallerOwned created above. | 44 // Destroy the string BeginReceiveCallerOwned created above. |
45 var_interface_->Release(var); | 45 var_interface_->Release(var); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 PP_Var HostVarSerializationRules::ReceivePassRef(const PP_Var& var, | 49 PP_Var HostVarSerializationRules::ReceivePassRef(const PP_Var& var, |
50 const std::string& str_val, | 50 const std::string& str_val, |
51 Dispatcher* /* dispatcher */) { | 51 Dispatcher* /* dispatcher */) { |
52 if (var.type == PP_VARTYPE_STRING) { | 52 if (var.type == PP_VARTYPE_STRING) { |
53 // Convert the string to the context of the current process. | 53 // Convert the string to the context of the current process. |
54 return var_interface_->VarFromUtf8(pp_module_, str_val.c_str(), | 54 return var_interface_->VarFromUtf8(str_val.c_str(), |
55 static_cast<uint32_t>(str_val.size())); | 55 static_cast<uint32_t>(str_val.size())); |
56 } | 56 } |
57 | 57 |
58 // See PluginVarSerialization::BeginSendPassRef for an example. | 58 // See PluginVarSerialization::BeginSendPassRef for an example. |
59 if (var.type == PP_VARTYPE_OBJECT) | 59 if (var.type == PP_VARTYPE_OBJECT) |
60 var_interface_->AddRef(var); | 60 var_interface_->AddRef(var); |
61 return var; | 61 return var; |
62 } | 62 } |
63 | 63 |
64 PP_Var HostVarSerializationRules::BeginSendPassRef(const PP_Var& var, | 64 PP_Var HostVarSerializationRules::BeginSendPassRef(const PP_Var& var, |
(...skipping 22 matching lines...) Expand all Loading... |
87 const char* data = var_interface_->VarToUtf8(var, &len); | 87 const char* data = var_interface_->VarToUtf8(var, &len); |
88 str->assign(data, len); | 88 str->assign(data, len); |
89 } | 89 } |
90 | 90 |
91 void HostVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { | 91 void HostVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { |
92 var_interface_->Release(var); | 92 var_interface_->Release(var); |
93 } | 93 } |
94 | 94 |
95 } // namespace proxy | 95 } // namespace proxy |
96 } // namespace ppapi | 96 } // namespace ppapi |
OLD | NEW |