| OLD | NEW |
| 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_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" |
| (...skipping 123 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 | |
| 159 ArrayBufferVar* PluginVarTracker::CreateArrayBuffer(uint32 size_in_bytes) { | 144 ArrayBufferVar* PluginVarTracker::CreateArrayBuffer(uint32 size_in_bytes) { |
| 160 return new PluginArrayBufferVar(size_in_bytes); | 145 return new PluginArrayBufferVar(size_in_bytes); |
| 161 } | 146 } |
| 162 | 147 |
| 163 int32 PluginVarTracker::AddVarInternal(Var* var, AddVarRefMode mode) { | 148 int32 PluginVarTracker::AddVarInternal(Var* var, AddVarRefMode mode) { |
| 164 // Normal adding. | 149 // Normal adding. |
| 165 int32 new_id = VarTracker::AddVarInternal(var, mode); | 150 int32 new_id = VarTracker::AddVarInternal(var, mode); |
| 166 | 151 |
| 167 // Need to add proxy objects to the host var map. | 152 // Need to add proxy objects to the host var map. |
| 168 ProxyObjectVar* proxy_object = var->AsProxyObjectVar(); | 153 ProxyObjectVar* proxy_object = var->AsProxyObjectVar(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 VarMap::iterator ret = live_vars_.find(found->second); | 255 VarMap::iterator ret = live_vars_.find(found->second); |
| 271 DCHECK(ret != live_vars_.end()); | 256 DCHECK(ret != live_vars_.end()); |
| 272 | 257 |
| 273 // All objects should be proxy objects. | 258 // All objects should be proxy objects. |
| 274 DCHECK(ret->second.var->AsProxyObjectVar()); | 259 DCHECK(ret->second.var->AsProxyObjectVar()); |
| 275 return scoped_refptr<ProxyObjectVar>(ret->second.var->AsProxyObjectVar()); | 260 return scoped_refptr<ProxyObjectVar>(ret->second.var->AsProxyObjectVar()); |
| 276 } | 261 } |
| 277 | 262 |
| 278 } // namesace proxy | 263 } // namesace proxy |
| 279 } // namespace ppapi | 264 } // namespace ppapi |
| OLD | NEW |