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

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

Issue 6286070: Remove all uses of the global Dispatcher Get function. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « ppapi/proxy/plugin_resource_tracker_unittest.cc ('k') | ppapi/proxy/plugin_var_tracker.h » ('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 "ppapi/proxy/plugin_dispatcher.h" 8 #include "ppapi/proxy/plugin_dispatcher.h"
8 #include "ppapi/proxy/plugin_var_tracker.h" 9 #include "ppapi/proxy/plugin_var_tracker.h"
9 10
10 namespace pp { 11 namespace pp {
11 namespace proxy { 12 namespace proxy {
12 13
13 PluginVarSerializationRules::PluginVarSerializationRules() 14 PluginVarSerializationRules::PluginVarSerializationRules()
14 : var_tracker_(PluginVarTracker::GetInstance()) { 15 : var_tracker_(PluginVarTracker::GetInstance()) {
15 } 16 }
16 17
(...skipping 18 matching lines...) Expand all
35 const std::string* str_val, 36 const std::string* str_val,
36 Dispatcher* dispatcher) { 37 Dispatcher* dispatcher) {
37 if (var.type == PP_VARTYPE_STRING) { 38 if (var.type == PP_VARTYPE_STRING) {
38 // Convert the string to the context of the current process. 39 // Convert the string to the context of the current process.
39 PP_Var ret; 40 PP_Var ret;
40 ret.type = PP_VARTYPE_STRING; 41 ret.type = PP_VARTYPE_STRING;
41 ret.value.as_id = var_tracker_->MakeString(*str_val); 42 ret.value.as_id = var_tracker_->MakeString(*str_val);
42 return ret; 43 return ret;
43 } 44 }
44 45
45 if (var.type == PP_VARTYPE_OBJECT) 46 if (var.type == PP_VARTYPE_OBJECT) {
46 return var_tracker_->TrackObjectWithNoReference(var, dispatcher); 47 DCHECK(dispatcher->IsPlugin());
48 return var_tracker_->TrackObjectWithNoReference(
49 var, static_cast<PluginDispatcher*>(dispatcher));
50 }
47 51
48 return var; 52 return var;
49 } 53 }
50 54
51 void PluginVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { 55 void PluginVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) {
52 if (var.type == PP_VARTYPE_STRING) { 56 if (var.type == PP_VARTYPE_STRING) {
53 // Destroy the string BeginReceiveCallerOwned created above. 57 // Destroy the string BeginReceiveCallerOwned created above.
54 var_tracker_->Release(var); 58 var_tracker_->Release(var);
55 } else if (var.type == PP_VARTYPE_OBJECT) { 59 } else if (var.type == PP_VARTYPE_OBJECT) {
56 var_tracker_->StopTrackingObjectWithNoReference(var); 60 var_tracker_->StopTrackingObjectWithNoReference(var);
(...skipping 21 matching lines...) Expand all
78 // Browser calls EndSendPassRef 4 1 1 1 82 // Browser calls EndSendPassRef 4 1 1 1
79 // 83 //
80 // In example 1 before the send, the plugin has 3 refs which are represented 84 // In example 1 before the send, the plugin has 3 refs which are represented
81 // as one ref in the browser (since the plugin only tells the browser when 85 // as one ref in the browser (since the plugin only tells the browser when
82 // it's refcount goes from 1 -> 0). The initial state is that the browser 86 // it's refcount goes from 1 -> 0). The initial state is that the browser
83 // plugin code started to return a value, which means it gets another ref 87 // plugin code started to return a value, which means it gets another ref
84 // on behalf of the caller. This needs to be transferred to the plugin and 88 // on behalf of the caller. This needs to be transferred to the plugin and
85 // folded in to its set of refs it maintains (with one ref representing all 89 // folded in to its set of refs it maintains (with one ref representing all
86 // fo them in the browser). 90 // fo them in the browser).
87 if (var.type == PP_VARTYPE_OBJECT) { 91 if (var.type == PP_VARTYPE_OBJECT) {
88 return var_tracker_->ReceiveObjectPassRef(var, dispatcher); 92 DCHECK(dispatcher->IsPlugin());
93 return var_tracker_->ReceiveObjectPassRef(
94 var, static_cast<PluginDispatcher*>(dispatcher));
89 } 95 }
90 96
91 // Other types are unchanged. 97 // Other types are unchanged.
92 return var; 98 return var;
93 } 99 }
94 100
95 PP_Var PluginVarSerializationRules::BeginSendPassRef(const PP_Var& var, 101 PP_Var PluginVarSerializationRules::BeginSendPassRef(const PP_Var& var,
96 std::string* str_val) { 102 std::string* str_val) {
97 // Overview of sending an object with "pass ref" from the plugin to the 103 // Overview of sending an object with "pass ref" from the plugin to the
98 // browser: 104 // browser:
(...skipping 18 matching lines...) Expand all
117 *str_val = var_tracker_->GetString(var); 123 *str_val = var_tracker_->GetString(var);
118 return var; 124 return var;
119 } 125 }
120 126
121 void PluginVarSerializationRules::EndSendPassRef(const PP_Var& var, 127 void PluginVarSerializationRules::EndSendPassRef(const PP_Var& var,
122 Dispatcher* dispatcher) { 128 Dispatcher* dispatcher) {
123 // See BeginSendPassRef for an example of why we release our ref here. 129 // See BeginSendPassRef for an example of why we release our ref here.
124 // The var we have in our inner class has been converted to a host object 130 // The var we have in our inner class has been converted to a host object
125 // by BeginSendPassRef. This means it's not a normal var valid in the plugin, 131 // by BeginSendPassRef. This means it's not a normal var valid in the plugin,
126 // so we need to use the special ReleaseHostObject. 132 // so we need to use the special ReleaseHostObject.
127 if (var.type == PP_VARTYPE_OBJECT) 133 if (var.type == PP_VARTYPE_OBJECT) {
128 var_tracker_->ReleaseHostObject(dispatcher, var); 134 var_tracker_->ReleaseHostObject(
135 static_cast<PluginDispatcher*>(dispatcher), var);
136 }
129 } 137 }
130 138
131 void PluginVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { 139 void PluginVarSerializationRules::ReleaseObjectRef(const PP_Var& var) {
132 var_tracker_->Release(var); 140 var_tracker_->Release(var);
133 } 141 }
134 142
135 } // namespace proxy 143 } // namespace proxy
136 } // namespace pp 144 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_resource_tracker_unittest.cc ('k') | ppapi/proxy/plugin_var_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698