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

Side by Side Diff: ppapi/shared_impl/var_tracker.cc

Issue 23809016: [PPAPI] ResourceVar now reference counts its PP_Resource in the plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix Windows compile. Created 7 years, 3 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
« no previous file with comments | « ppapi/shared_impl/var_tracker.h ('k') | no next file » | 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/shared_impl/var_tracker.h" 5 #include "ppapi/shared_impl/var_tracker.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "ppapi/shared_impl/host_resource.h" 13 #include "ppapi/shared_impl/host_resource.h"
14 #include "ppapi/shared_impl/id_assignment.h" 14 #include "ppapi/shared_impl/id_assignment.h"
15 #include "ppapi/shared_impl/proxy_lock.h" 15 #include "ppapi/shared_impl/proxy_lock.h"
16 #include "ppapi/shared_impl/resource_var.h"
16 #include "ppapi/shared_impl/var.h" 17 #include "ppapi/shared_impl/var.h"
17 18
18 namespace ppapi { 19 namespace ppapi {
19 20
20 VarTracker::VarInfo::VarInfo() 21 VarTracker::VarInfo::VarInfo()
21 : var(), 22 : var(),
22 ref_count(0), 23 ref_count(0),
23 track_with_no_reference_count(0) { 24 track_with_no_reference_count(0) {
24 } 25 }
25 26
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 base::SharedMemoryHandle handle) { 228 base::SharedMemoryHandle handle) {
228 CheckThreadingPreconditions(); 229 CheckThreadingPreconditions();
229 230
230 scoped_refptr<ArrayBufferVar> array_buffer( 231 scoped_refptr<ArrayBufferVar> array_buffer(
231 CreateShmArrayBuffer(size_in_bytes, handle)); 232 CreateShmArrayBuffer(size_in_bytes, handle));
232 if (!array_buffer.get()) 233 if (!array_buffer.get())
233 return PP_MakeNull(); 234 return PP_MakeNull();
234 return array_buffer->GetPPVar(); 235 return array_buffer->GetPPVar();
235 } 236 }
236 237
238 PP_Var VarTracker::MakeResourcePPVar(PP_Resource pp_resource) {
239 CheckThreadingPreconditions();
240
241 ResourceVar* resource_var = MakeResourceVar(pp_resource);
242 return resource_var ? resource_var->GetPPVar() : PP_MakeNull();
243 }
244
237 std::vector<PP_Var> VarTracker::GetLiveVars() { 245 std::vector<PP_Var> VarTracker::GetLiveVars() {
238 CheckThreadingPreconditions(); 246 CheckThreadingPreconditions();
239 247
240 std::vector<PP_Var> var_vector; 248 std::vector<PP_Var> var_vector;
241 var_vector.reserve(live_vars_.size()); 249 var_vector.reserve(live_vars_.size());
242 for (VarMap::const_iterator iter = live_vars_.begin(); 250 for (VarMap::const_iterator iter = live_vars_.begin();
243 iter != live_vars_.end(); 251 iter != live_vars_.end();
244 ++iter) { 252 ++iter) {
245 var_vector.push_back(iter->second.var->GetPPVar()); 253 var_vector.push_back(iter->second.var->GetPPVar());
246 } 254 }
(...skipping 12 matching lines...) Expand all
259 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { 267 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) {
260 if (iter->second.ref_count != 0 || 268 if (iter->second.ref_count != 0 ||
261 iter->second.track_with_no_reference_count != 0) 269 iter->second.track_with_no_reference_count != 0)
262 return false; // Object still alive. 270 return false; // Object still alive.
263 iter->second.var->ResetVarID(); 271 iter->second.var->ResetVarID();
264 live_vars_.erase(iter); 272 live_vars_.erase(iter);
265 return true; 273 return true;
266 } 274 }
267 275
268 } // namespace ppapi 276 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/var_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698