OLD | NEW |
1 // Copyright (c) 2012 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_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/ppb_var.h" | 9 #include "ppapi/c/ppb_var.h" |
10 #include "ppapi/proxy/plugin_array_buffer_var.h" | 10 #include "ppapi/proxy/plugin_array_buffer_var.h" |
11 #include "ppapi/proxy/plugin_dispatcher.h" | 11 #include "ppapi/proxy/plugin_dispatcher.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 HostVar(dispatcher, static_cast<int32>(host_object.value.as_id))); | 134 HostVar(dispatcher, static_cast<int32>(host_object.value.as_id))); |
135 if (found == host_var_to_plugin_var_.end()) { | 135 if (found == host_var_to_plugin_var_.end()) { |
136 NOTREACHED(); | 136 NOTREACHED(); |
137 return; | 137 return; |
138 } | 138 } |
139 | 139 |
140 // Now just release the object given the plugin var ID. | 140 // Now just release the object given the plugin var ID. |
141 ReleaseVar(found->second); | 141 ReleaseVar(found->second); |
142 } | 142 } |
143 | 143 |
| 144 int PluginVarTracker::GetRefCountForObject(const PP_Var& plugin_object) { |
| 145 VarMap::iterator found = GetLiveVar(plugin_object); |
| 146 if (found == live_vars_.end()) |
| 147 return -1; |
| 148 return found->second.ref_count; |
| 149 } |
| 150 |
| 151 int PluginVarTracker::GetTrackedWithNoReferenceCountForObject( |
| 152 const PP_Var& plugin_object) { |
| 153 VarMap::iterator found = GetLiveVar(plugin_object); |
| 154 if (found == live_vars_.end()) |
| 155 return -1; |
| 156 return found->second.track_with_no_reference_count; |
| 157 } |
| 158 |
144 ArrayBufferVar* PluginVarTracker::CreateArrayBuffer(uint32 size_in_bytes) { | 159 ArrayBufferVar* PluginVarTracker::CreateArrayBuffer(uint32 size_in_bytes) { |
145 return new PluginArrayBufferVar(size_in_bytes); | 160 return new PluginArrayBufferVar(size_in_bytes); |
146 } | 161 } |
147 | 162 |
148 int32 PluginVarTracker::AddVarInternal(Var* var, AddVarRefMode mode) { | 163 int32 PluginVarTracker::AddVarInternal(Var* var, AddVarRefMode mode) { |
149 // Normal adding. | 164 // Normal adding. |
150 int32 new_id = VarTracker::AddVarInternal(var, mode); | 165 int32 new_id = VarTracker::AddVarInternal(var, mode); |
151 | 166 |
152 // Need to add proxy objects to the host var map. | 167 // Need to add proxy objects to the host var map. |
153 ProxyObjectVar* proxy_object = var->AsProxyObjectVar(); | 168 ProxyObjectVar* proxy_object = var->AsProxyObjectVar(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 VarMap::iterator ret = live_vars_.find(found->second); | 270 VarMap::iterator ret = live_vars_.find(found->second); |
256 DCHECK(ret != live_vars_.end()); | 271 DCHECK(ret != live_vars_.end()); |
257 | 272 |
258 // All objects should be proxy objects. | 273 // All objects should be proxy objects. |
259 DCHECK(ret->second.var->AsProxyObjectVar()); | 274 DCHECK(ret->second.var->AsProxyObjectVar()); |
260 return scoped_refptr<ProxyObjectVar>(ret->second.var->AsProxyObjectVar()); | 275 return scoped_refptr<ProxyObjectVar>(ret->second.var->AsProxyObjectVar()); |
261 } | 276 } |
262 | 277 |
263 } // namesace proxy | 278 } // namesace proxy |
264 } // namespace ppapi | 279 } // namespace ppapi |
OLD | NEW |