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

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

Issue 12378050: PPAPI: Remove threading options; it's always on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PDFResource unit test Created 7 years, 8 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/ppapi_proxy_test.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) 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_tracker.h" 5 #include "ppapi/proxy/plugin_var_tracker.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "ppapi/c/dev/ppp_class_deprecated.h" 9 #include "ppapi/c/dev/ppp_class_deprecated.h"
10 #include "ppapi/c/ppb_var.h" 10 #include "ppapi/c/ppb_var.h"
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 bool PluginVarTracker::HostVar::operator<(const HostVar& other) const { 26 bool PluginVarTracker::HostVar::operator<(const HostVar& other) const {
27 if (dispatcher < other.dispatcher) 27 if (dispatcher < other.dispatcher)
28 return true; 28 return true;
29 if (other.dispatcher < dispatcher) 29 if (other.dispatcher < dispatcher)
30 return false; 30 return false;
31 return host_object_id < other.host_object_id; 31 return host_object_id < other.host_object_id;
32 } 32 }
33 33
34 PluginVarTracker::PluginVarTracker() { 34 PluginVarTracker::PluginVarTracker() : VarTracker(THREAD_SAFE) {
35 } 35 }
36 36
37 PluginVarTracker::~PluginVarTracker() { 37 PluginVarTracker::~PluginVarTracker() {
38 } 38 }
39 39
40 PP_Var PluginVarTracker::ReceiveObjectPassRef(const PP_Var& host_var, 40 PP_Var PluginVarTracker::ReceiveObjectPassRef(const PP_Var& host_var,
41 PluginDispatcher* dispatcher) { 41 PluginDispatcher* dispatcher) {
42 DCHECK(CalledOnValidThread()); 42 CheckThreadingPreconditions();
43 DCHECK(host_var.type == PP_VARTYPE_OBJECT); 43 DCHECK(host_var.type == PP_VARTYPE_OBJECT);
44 44
45 // Get the object. 45 // Get the object.
46 scoped_refptr<ProxyObjectVar> object( 46 scoped_refptr<ProxyObjectVar> object(
47 FindOrMakePluginVarFromHostVar(host_var, dispatcher)); 47 FindOrMakePluginVarFromHostVar(host_var, dispatcher));
48 48
49 // Actually create the PP_Var, this will add all the tracking info but not 49 // Actually create the PP_Var, this will add all the tracking info but not
50 // adjust any refcounts. 50 // adjust any refcounts.
51 PP_Var ret = GetOrCreateObjectVarID(object.get()); 51 PP_Var ret = GetOrCreateObjectVarID(object.get());
52 52
53 VarInfo& info = GetLiveVar(ret)->second; 53 VarInfo& info = GetLiveVar(ret)->second;
54 if (info.ref_count > 0) { 54 if (info.ref_count > 0) {
55 // We already had a reference to it before. That means the renderer now has 55 // We already had a reference to it before. That means the renderer now has
56 // two references on our behalf. We want to transfer that extra reference 56 // two references on our behalf. We want to transfer that extra reference
57 // to our list. This means we addref in the plugin, and release the extra 57 // to our list. This means we addref in the plugin, and release the extra
58 // one in the renderer. 58 // one in the renderer.
59 SendReleaseObjectMsg(*object); 59 SendReleaseObjectMsg(*object);
60 } 60 }
61 info.ref_count++; 61 info.ref_count++;
62 return ret; 62 return ret;
63 } 63 }
64 64
65 PP_Var PluginVarTracker::TrackObjectWithNoReference( 65 PP_Var PluginVarTracker::TrackObjectWithNoReference(
66 const PP_Var& host_var, 66 const PP_Var& host_var,
67 PluginDispatcher* dispatcher) { 67 PluginDispatcher* dispatcher) {
68 DCHECK(CalledOnValidThread()); 68 CheckThreadingPreconditions();
69 DCHECK(host_var.type == PP_VARTYPE_OBJECT); 69 DCHECK(host_var.type == PP_VARTYPE_OBJECT);
70 70
71 // Get the object. 71 // Get the object.
72 scoped_refptr<ProxyObjectVar> object( 72 scoped_refptr<ProxyObjectVar> object(
73 FindOrMakePluginVarFromHostVar(host_var, dispatcher)); 73 FindOrMakePluginVarFromHostVar(host_var, dispatcher));
74 74
75 // Actually create the PP_Var, this will add all the tracking info but not 75 // Actually create the PP_Var, this will add all the tracking info but not
76 // adjust any refcounts. 76 // adjust any refcounts.
77 PP_Var ret = GetOrCreateObjectVarID(object.get()); 77 PP_Var ret = GetOrCreateObjectVarID(object.get());
78 78
79 VarInfo& info = GetLiveVar(ret)->second; 79 VarInfo& info = GetLiveVar(ret)->second;
80 info.track_with_no_reference_count++; 80 info.track_with_no_reference_count++;
81 return ret; 81 return ret;
82 } 82 }
83 83
84 void PluginVarTracker::StopTrackingObjectWithNoReference( 84 void PluginVarTracker::StopTrackingObjectWithNoReference(
85 const PP_Var& plugin_var) { 85 const PP_Var& plugin_var) {
86 DCHECK(CalledOnValidThread()); 86 CheckThreadingPreconditions();
87 DCHECK(plugin_var.type == PP_VARTYPE_OBJECT); 87 DCHECK(plugin_var.type == PP_VARTYPE_OBJECT);
88 88
89 VarMap::iterator found = GetLiveVar(plugin_var); 89 VarMap::iterator found = GetLiveVar(plugin_var);
90 if (found == live_vars_.end()) { 90 if (found == live_vars_.end()) {
91 NOTREACHED(); 91 NOTREACHED();
92 return; 92 return;
93 } 93 }
94 94
95 DCHECK(found->second.track_with_no_reference_count > 0); 95 DCHECK(found->second.track_with_no_reference_count > 0);
96 found->second.track_with_no_reference_count--; 96 found->second.track_with_no_reference_count--;
97 DeleteObjectInfoIfNecessary(found); 97 DeleteObjectInfoIfNecessary(found);
98 } 98 }
99 99
100 PP_Var PluginVarTracker::GetHostObject(const PP_Var& plugin_object) const { 100 PP_Var PluginVarTracker::GetHostObject(const PP_Var& plugin_object) const {
101 DCHECK(CalledOnValidThread()); 101 CheckThreadingPreconditions();
102
103 if (plugin_object.type != PP_VARTYPE_OBJECT) { 102 if (plugin_object.type != PP_VARTYPE_OBJECT) {
104 NOTREACHED(); 103 NOTREACHED();
105 return PP_MakeUndefined(); 104 return PP_MakeUndefined();
106 } 105 }
107 106
108 Var* var = GetVar(plugin_object); 107 Var* var = GetVar(plugin_object);
109 ProxyObjectVar* object = var->AsProxyObjectVar(); 108 ProxyObjectVar* object = var->AsProxyObjectVar();
110 if (!object) { 109 if (!object) {
111 NOTREACHED(); 110 NOTREACHED();
112 return PP_MakeUndefined(); 111 return PP_MakeUndefined();
113 } 112 }
114 113
115 // Make a var with the host ID. 114 // Make a var with the host ID.
116 PP_Var ret = { PP_VARTYPE_OBJECT }; 115 PP_Var ret = { PP_VARTYPE_OBJECT };
117 ret.value.as_id = object->host_var_id(); 116 ret.value.as_id = object->host_var_id();
118 return ret; 117 return ret;
119 } 118 }
120 119
121 PluginDispatcher* PluginVarTracker::DispatcherForPluginObject( 120 PluginDispatcher* PluginVarTracker::DispatcherForPluginObject(
122 const PP_Var& plugin_object) const { 121 const PP_Var& plugin_object) const {
123 DCHECK(CalledOnValidThread()); 122 CheckThreadingPreconditions();
124
125 if (plugin_object.type != PP_VARTYPE_OBJECT) 123 if (plugin_object.type != PP_VARTYPE_OBJECT)
126 return NULL; 124 return NULL;
127 125
128 VarMap::const_iterator found = GetLiveVar(plugin_object); 126 VarMap::const_iterator found = GetLiveVar(plugin_object);
129 if (found == live_vars_.end()) 127 if (found == live_vars_.end())
130 return NULL; 128 return NULL;
131 129
132 ProxyObjectVar* object = found->second.var->AsProxyObjectVar(); 130 ProxyObjectVar* object = found->second.var->AsProxyObjectVar();
133 if (!object) 131 if (!object)
134 return NULL; 132 return NULL;
135 return object->dispatcher(); 133 return object->dispatcher();
136 } 134 }
137 135
138 void PluginVarTracker::ReleaseHostObject(PluginDispatcher* dispatcher, 136 void PluginVarTracker::ReleaseHostObject(PluginDispatcher* dispatcher,
139 const PP_Var& host_object) { 137 const PP_Var& host_object) {
140 DCHECK(CalledOnValidThread()); 138 CheckThreadingPreconditions();
141 DCHECK(host_object.type == PP_VARTYPE_OBJECT); 139 DCHECK(host_object.type == PP_VARTYPE_OBJECT);
142 140
143 // Convert the host object to a normal var valid in the plugin. 141 // Convert the host object to a normal var valid in the plugin.
144 HostVarToPluginVarMap::iterator found = host_var_to_plugin_var_.find( 142 HostVarToPluginVarMap::iterator found = host_var_to_plugin_var_.find(
145 HostVar(dispatcher, static_cast<int32>(host_object.value.as_id))); 143 HostVar(dispatcher, static_cast<int32>(host_object.value.as_id)));
146 if (found == host_var_to_plugin_var_.end()) { 144 if (found == host_var_to_plugin_var_.end()) {
147 NOTREACHED(); 145 NOTREACHED();
148 return; 146 return;
149 } 147 }
150 148
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 int id, 384 int id,
387 PP_Instance instance, 385 PP_Instance instance,
388 base::SharedMemoryHandle* handle, 386 base::SharedMemoryHandle* handle,
389 uint32* size_in_bytes) { 387 uint32* size_in_bytes) {
390 NOTREACHED(); 388 NOTREACHED();
391 return false; 389 return false;
392 } 390 }
393 391
394 } // namesace proxy 392 } // namesace proxy
395 } // namespace ppapi 393 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_resource_tracker_unittest.cc ('k') | ppapi/proxy/ppapi_proxy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698