Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: ppapi/proxy/plugin_var_serialization_rules.cc

Issue 7621054: Don't use a scoped_refptr for StringVar::FromPPVar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/proxy/ppb_font_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/plugin_var_serialization_rules.h" 5 #include "ppapi/proxy/plugin_var_serialization_rules.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ppapi/proxy/plugin_dispatcher.h" 8 #include "ppapi/proxy/plugin_dispatcher.h"
9 #include "ppapi/proxy/plugin_resource_tracker.h" 9 #include "ppapi/proxy/plugin_resource_tracker.h"
10 #include "ppapi/proxy/plugin_var_tracker.h" 10 #include "ppapi/proxy/plugin_var_tracker.h"
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 PP_Var PluginVarSerializationRules::SendCallerOwned(const PP_Var& var, 23 PP_Var PluginVarSerializationRules::SendCallerOwned(const PP_Var& var,
24 std::string* str_val) { 24 std::string* str_val) {
25 // Objects need special translations to get the IDs valid in the host. 25 // Objects need special translations to get the IDs valid in the host.
26 if (var.type == PP_VARTYPE_OBJECT) 26 if (var.type == PP_VARTYPE_OBJECT)
27 return var_tracker_->GetHostObject(var); 27 return var_tracker_->GetHostObject(var);
28 28
29 // Retrieve the string to use for IPC. 29 // Retrieve the string to use for IPC.
30 if (var.type == PP_VARTYPE_STRING) { 30 if (var.type == PP_VARTYPE_STRING) {
31 scoped_refptr<StringVar> string_var(StringVar::FromPPVar(var)); 31 StringVar* string_var = StringVar::FromPPVar(var);
32 if (string_var.get()) 32 if (string_var)
33 *str_val = string_var->value(); 33 *str_val = string_var->value();
34 else 34 else
35 NOTREACHED() << "Trying to send unknown string over IPC."; 35 NOTREACHED() << "Trying to send unknown string over IPC.";
36 } 36 }
37 return var; 37 return var;
38 } 38 }
39 39
40 PP_Var PluginVarSerializationRules::BeginReceiveCallerOwned( 40 PP_Var PluginVarSerializationRules::BeginReceiveCallerOwned(
41 const PP_Var& var, 41 const PP_Var& var,
42 const std::string* str_val, 42 const std::string* str_val,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // entire ref count in the plugin. When the plugin refcount goes to 0, it 109 // entire ref count in the plugin. When the plugin refcount goes to 0, it
110 // will call the browser to deref the object. This is why in example 2 110 // will call the browser to deref the object. This is why in example 2
111 // transferring the object ref to the browser involves no net change in the 111 // transferring the object ref to the browser involves no net change in the
112 // browser's refcount. 112 // browser's refcount.
113 113
114 // Objects need special translations to get the IDs valid in the host. 114 // Objects need special translations to get the IDs valid in the host.
115 if (var.type == PP_VARTYPE_OBJECT) 115 if (var.type == PP_VARTYPE_OBJECT)
116 return var_tracker_->GetHostObject(var); 116 return var_tracker_->GetHostObject(var);
117 117
118 if (var.type == PP_VARTYPE_STRING) { 118 if (var.type == PP_VARTYPE_STRING) {
119 scoped_refptr<StringVar> string_var(StringVar::FromPPVar(var)); 119 StringVar* string_var = StringVar::FromPPVar(var);
120 if (string_var.get()) 120 if (string_var)
121 *str_val = string_var->value(); 121 *str_val = string_var->value();
122 else 122 else
123 NOTREACHED() << "Trying to send unknown string over IPC."; 123 NOTREACHED() << "Trying to send unknown string over IPC.";
124 } 124 }
125 return var; 125 return var;
126 } 126 }
127 127
128 void PluginVarSerializationRules::EndSendPassRef(const PP_Var& var, 128 void PluginVarSerializationRules::EndSendPassRef(const PP_Var& var,
129 Dispatcher* dispatcher) { 129 Dispatcher* dispatcher) {
130 // See BeginSendPassRef for an example of why we release our ref here. 130 // See BeginSendPassRef for an example of why we release our ref here.
131 // The var we have in our inner class has been converted to a host object 131 // The var we have in our inner class has been converted to a host object
132 // by BeginSendPassRef. This means it's not a normal var valid in the plugin, 132 // by BeginSendPassRef. This means it's not a normal var valid in the plugin,
133 // so we need to use the special ReleaseHostObject. 133 // so we need to use the special ReleaseHostObject.
134 if (var.type == PP_VARTYPE_OBJECT) { 134 if (var.type == PP_VARTYPE_OBJECT) {
135 var_tracker_->ReleaseHostObject( 135 var_tracker_->ReleaseHostObject(
136 static_cast<PluginDispatcher*>(dispatcher), var); 136 static_cast<PluginDispatcher*>(dispatcher), var);
137 } 137 }
138 } 138 }
139 139
140 void PluginVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { 140 void PluginVarSerializationRules::ReleaseObjectRef(const PP_Var& var) {
141 var_tracker_->ReleaseVar(var); 141 var_tracker_->ReleaseVar(var);
142 } 142 }
143 143
144 } // namespace proxy 144 } // namespace proxy
145 } // namespace ppapi 145 } // namespace ppapi
OLDNEW
« no previous file with comments | « no previous file | ppapi/proxy/ppb_font_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698