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" | 7 #include "base/logging.h" |
8 #include "ppapi/c/ppb_var.h" | 8 #include "ppapi/c/ppb_var.h" |
9 #include "ppapi/shared_impl/ppapi_globals.h" | 9 #include "ppapi/shared_impl/ppapi_globals.h" |
10 #include "ppapi/shared_impl/var.h" | 10 #include "ppapi/shared_impl/var.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 return var; | 28 return var; |
29 } | 29 } |
30 | 30 |
31 PP_Var HostVarSerializationRules::BeginReceiveCallerOwned( | 31 PP_Var HostVarSerializationRules::BeginReceiveCallerOwned( |
32 const PP_Var& var, | 32 const PP_Var& var, |
33 Dispatcher* /* dispatcher */) { | 33 Dispatcher* /* dispatcher */) { |
34 return var; | 34 return var; |
35 } | 35 } |
36 | 36 |
37 void HostVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { | 37 void HostVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { |
38 if (var.type == PP_VARTYPE_STRING) { | 38 if (var.type != PP_VARTYPE_OBJECT && var.type >= PP_VARTYPE_STRING) { |
39 // Destroy the string. | 39 // Release our reference to the local Var. |
40 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); | 40 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 PP_Var HostVarSerializationRules::ReceivePassRef( | 44 PP_Var HostVarSerializationRules::ReceivePassRef( |
45 const PP_Var& var, | 45 const PP_Var& var, |
46 Dispatcher* /* dispatcher */) { | 46 Dispatcher* /* dispatcher */) { |
47 // See PluginVarSerialization::BeginSendPassRef for an example. | 47 // See PluginVarSerialization::BeginSendPassRef for an example. |
48 if (var.type == PP_VARTYPE_OBJECT) | 48 if (var.type == PP_VARTYPE_OBJECT) |
49 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); | 49 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); |
50 return var; | 50 return var; |
51 } | 51 } |
52 | 52 |
53 PP_Var HostVarSerializationRules::BeginSendPassRef(const PP_Var& var) { | 53 PP_Var HostVarSerializationRules::BeginSendPassRef(const PP_Var& var) { |
54 return var; | 54 return var; |
55 } | 55 } |
56 | 56 |
57 void HostVarSerializationRules::EndSendPassRef(const PP_Var& /* var */, | 57 void HostVarSerializationRules::EndSendPassRef(const PP_Var& /* var */, |
58 Dispatcher* /* dispatcher */) { | 58 Dispatcher* /* dispatcher */) { |
59 // See PluginVarSerialization::ReceivePassRef for an example. We don't need | 59 // See PluginVarSerialization::ReceivePassRef for an example. We don't need |
60 // to do anything here. | 60 // to do anything here. |
61 } | 61 } |
62 | 62 |
63 void HostVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { | 63 void HostVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { |
64 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); | 64 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); |
65 } | 65 } |
66 | 66 |
67 } // namespace proxy | 67 } // namespace proxy |
68 } // namespace ppapi | 68 } // namespace ppapi |
OLD | NEW |