OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" | |
8 #include "ppapi/c/ppb_var.h" | |
9 #include "ppapi/shared_impl/ppapi_globals.h" | 7 #include "ppapi/shared_impl/ppapi_globals.h" |
10 #include "ppapi/shared_impl/var.h" | |
11 #include "ppapi/shared_impl/var_tracker.h" | 8 #include "ppapi/shared_impl/var_tracker.h" |
12 | 9 |
13 using ppapi::PpapiGlobals; | 10 using ppapi::PpapiGlobals; |
14 using ppapi::StringVar; | |
15 using ppapi::VarTracker; | 11 using ppapi::VarTracker; |
16 | 12 |
17 namespace ppapi { | 13 namespace ppapi { |
18 namespace proxy { | 14 namespace proxy { |
19 | 15 |
20 HostVarSerializationRules::HostVarSerializationRules(PP_Module pp_module) | 16 HostVarSerializationRules::HostVarSerializationRules() { |
21 : pp_module_(pp_module) { | |
22 } | 17 } |
23 | 18 |
24 HostVarSerializationRules::~HostVarSerializationRules() { | 19 HostVarSerializationRules::~HostVarSerializationRules() { |
25 } | 20 } |
26 | 21 |
27 PP_Var HostVarSerializationRules::SendCallerOwned(const PP_Var& var) { | 22 PP_Var HostVarSerializationRules::SendCallerOwned(const PP_Var& var) { |
28 return var; | 23 return var; |
29 } | 24 } |
30 | 25 |
31 PP_Var HostVarSerializationRules::BeginReceiveCallerOwned( | 26 PP_Var HostVarSerializationRules::BeginReceiveCallerOwned(const PP_Var& var) { |
32 const PP_Var& var, | |
33 Dispatcher* /* dispatcher */) { | |
34 return var; | 27 return var; |
35 } | 28 } |
36 | 29 |
37 void HostVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { | 30 void HostVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { |
38 if (var.type != PP_VARTYPE_OBJECT && var.type >= PP_VARTYPE_STRING) { | 31 if (var.type != PP_VARTYPE_OBJECT && var.type >= PP_VARTYPE_STRING) { |
39 // Release our reference to the local Var. | 32 // Release our reference to the local Var. |
40 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); | 33 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); |
41 } | 34 } |
42 } | 35 } |
43 | 36 |
44 PP_Var HostVarSerializationRules::ReceivePassRef( | 37 PP_Var HostVarSerializationRules::ReceivePassRef(const PP_Var& var) { |
45 const PP_Var& var, | |
46 Dispatcher* /* dispatcher */) { | |
47 // See PluginVarSerialization::BeginSendPassRef for an example. | 38 // See PluginVarSerialization::BeginSendPassRef for an example. |
48 if (var.type == PP_VARTYPE_OBJECT) | 39 if (var.type == PP_VARTYPE_OBJECT) |
49 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); | 40 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); |
50 return var; | 41 return var; |
51 } | 42 } |
52 | 43 |
53 PP_Var HostVarSerializationRules::BeginSendPassRef(const PP_Var& var) { | 44 PP_Var HostVarSerializationRules::BeginSendPassRef(const PP_Var& var) { |
54 return var; | 45 return var; |
55 } | 46 } |
56 | 47 |
57 void HostVarSerializationRules::EndSendPassRef(const PP_Var& /* var */, | 48 void HostVarSerializationRules::EndSendPassRef(const PP_Var& /* var */) { |
58 Dispatcher* /* dispatcher */) { | |
59 // See PluginVarSerialization::ReceivePassRef for an example. We don't need | 49 // See PluginVarSerialization::ReceivePassRef for an example. We don't need |
60 // to do anything here. | 50 // to do anything here. |
61 } | 51 } |
62 | 52 |
63 void HostVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { | 53 void HostVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { |
64 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); | 54 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); |
65 } | 55 } |
66 | 56 |
67 } // namespace proxy | 57 } // namespace proxy |
68 } // namespace ppapi | 58 } // namespace ppapi |
OLD | NEW |