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

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

Issue 16136005: Update remaining files to use WeakPtr<T>::get() instead of "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
OLDNEW
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/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_globals.h" 9 #include "ppapi/proxy/plugin_globals.h"
10 #include "ppapi/proxy/plugin_resource_tracker.h" 10 #include "ppapi/proxy/plugin_resource_tracker.h"
(...skipping 15 matching lines...) Expand all
26 26
27 PP_Var PluginVarSerializationRules::SendCallerOwned(const PP_Var& var) { 27 PP_Var PluginVarSerializationRules::SendCallerOwned(const PP_Var& var) {
28 // Objects need special translations to get the IDs valid in the host. 28 // Objects need special translations to get the IDs valid in the host.
29 if (var.type == PP_VARTYPE_OBJECT) 29 if (var.type == PP_VARTYPE_OBJECT)
30 return var_tracker_->GetHostObject(var); 30 return var_tracker_->GetHostObject(var);
31 return var; 31 return var;
32 } 32 }
33 33
34 PP_Var PluginVarSerializationRules::BeginReceiveCallerOwned(const PP_Var& var) { 34 PP_Var PluginVarSerializationRules::BeginReceiveCallerOwned(const PP_Var& var) {
35 if (var.type == PP_VARTYPE_OBJECT) { 35 if (var.type == PP_VARTYPE_OBJECT) {
36 return dispatcher_ ? 36 return dispatcher_.get() ? var_tracker_->TrackObjectWithNoReference(
37 var_tracker_->TrackObjectWithNoReference(var, dispatcher_) : 37 var, dispatcher_.get())
38 PP_MakeUndefined(); 38 : PP_MakeUndefined();
39 } 39 }
40 40
41 return var; 41 return var;
42 } 42 }
43 43
44 void PluginVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) { 44 void PluginVarSerializationRules::EndReceiveCallerOwned(const PP_Var& var) {
45 if (var.type == PP_VARTYPE_OBJECT) { 45 if (var.type == PP_VARTYPE_OBJECT) {
46 var_tracker_->StopTrackingObjectWithNoReference(var); 46 var_tracker_->StopTrackingObjectWithNoReference(var);
47 } else if (var.type >= PP_VARTYPE_STRING) { 47 } else if (var.type >= PP_VARTYPE_STRING) {
48 // Release our reference to the local Var. 48 // Release our reference to the local Var.
(...skipping 12 matching lines...) Expand all
61 // Browser calls EndSendPassRef 4 1 1 1 61 // Browser calls EndSendPassRef 4 1 1 1
62 // 62 //
63 // In example 1 before the send, the plugin has 3 refs which are represented 63 // In example 1 before the send, the plugin has 3 refs which are represented
64 // as one ref in the browser (since the plugin only tells the browser when 64 // as one ref in the browser (since the plugin only tells the browser when
65 // it's refcount goes from 1 -> 0). The initial state is that the browser 65 // it's refcount goes from 1 -> 0). The initial state is that the browser
66 // plugin code started to return a value, which means it gets another ref 66 // plugin code started to return a value, which means it gets another ref
67 // on behalf of the caller. This needs to be transferred to the plugin and 67 // on behalf of the caller. This needs to be transferred to the plugin and
68 // folded in to its set of refs it maintains (with one ref representing all 68 // folded in to its set of refs it maintains (with one ref representing all
69 // of them in the browser). 69 // of them in the browser).
70 if (var.type == PP_VARTYPE_OBJECT) { 70 if (var.type == PP_VARTYPE_OBJECT) {
71 return dispatcher_ ? 71 return dispatcher_.get()
72 var_tracker_->ReceiveObjectPassRef(var, dispatcher_) : 72 ? var_tracker_->ReceiveObjectPassRef(var, dispatcher_.get())
73 PP_MakeUndefined(); 73 : PP_MakeUndefined();
74 } 74 }
75 75
76 // Other types are unchanged. 76 // Other types are unchanged.
77 return var; 77 return var;
78 } 78 }
79 79
80 PP_Var PluginVarSerializationRules::BeginSendPassRef(const PP_Var& var) { 80 PP_Var PluginVarSerializationRules::BeginSendPassRef(const PP_Var& var) {
81 // Overview of sending an object with "pass ref" from the plugin to the 81 // Overview of sending an object with "pass ref" from the plugin to the
82 // browser: 82 // browser:
83 // Example 1 Example 2 83 // Example 1 Example 2
(...skipping 14 matching lines...) Expand all
98 return var_tracker_->GetHostObject(var); 98 return var_tracker_->GetHostObject(var);
99 return var; 99 return var;
100 } 100 }
101 101
102 void PluginVarSerializationRules::EndSendPassRef(const PP_Var& var) { 102 void PluginVarSerializationRules::EndSendPassRef(const PP_Var& var) {
103 // See BeginSendPassRef for an example of why we release our ref here. 103 // See BeginSendPassRef for an example of why we release our ref here.
104 // The var we have in our inner class has been converted to a host object 104 // The var we have in our inner class has been converted to a host object
105 // by BeginSendPassRef. This means it's not a normal var valid in the plugin, 105 // by BeginSendPassRef. This means it's not a normal var valid in the plugin,
106 // so we need to use the special ReleaseHostObject. 106 // so we need to use the special ReleaseHostObject.
107 if (var.type == PP_VARTYPE_OBJECT) { 107 if (var.type == PP_VARTYPE_OBJECT) {
108 if (dispatcher_) 108 if (dispatcher_.get())
109 var_tracker_->ReleaseHostObject(dispatcher_, var); 109 var_tracker_->ReleaseHostObject(dispatcher_.get(), var);
110 } else if (var.type >= PP_VARTYPE_STRING) { 110 } else if (var.type >= PP_VARTYPE_STRING) {
111 var_tracker_->ReleaseVar(var); 111 var_tracker_->ReleaseVar(var);
112 } 112 }
113 } 113 }
114 114
115 void PluginVarSerializationRules::ReleaseObjectRef(const PP_Var& var) { 115 void PluginVarSerializationRules::ReleaseObjectRef(const PP_Var& var) {
116 var_tracker_->ReleaseVar(var); 116 var_tracker_->ReleaseVar(var);
117 } 117 }
118 118
119 } // namespace proxy 119 } // namespace proxy
120 } // namespace ppapi 120 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698