OLD | NEW |
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 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // Basic refcount increment. | 83 // Basic refcount increment. |
84 info.ref_count++; | 84 info.ref_count++; |
85 return true; | 85 return true; |
86 } | 86 } |
87 | 87 |
88 bool VarTracker::AddRefVar(const PP_Var& var) { | 88 bool VarTracker::AddRefVar(const PP_Var& var) { |
89 DCHECK(CalledOnValidThread()); | 89 DCHECK(CalledOnValidThread()); |
90 ProxyLock::AssertAcquired(); | 90 ProxyLock::AssertAcquired(); |
91 | 91 |
92 if (!IsVarTypeRefcounted(var.type)) | 92 if (!IsVarTypeRefcounted(var.type)) |
93 return false; | 93 return true; |
94 return AddRefVar(static_cast<int32>(var.value.as_id)); | 94 return AddRefVar(static_cast<int32>(var.value.as_id)); |
95 } | 95 } |
96 | 96 |
97 bool VarTracker::ReleaseVar(int32 var_id) { | 97 bool VarTracker::ReleaseVar(int32 var_id) { |
98 DCHECK(CalledOnValidThread()); | 98 DCHECK(CalledOnValidThread()); |
99 ProxyLock::AssertAcquired(); | 99 ProxyLock::AssertAcquired(); |
100 | 100 |
101 DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR)) | 101 DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR)) |
102 << var_id << " is not a PP_Var ID."; | 102 << var_id << " is not a PP_Var ID."; |
103 VarMap::iterator found = live_vars_.find(var_id); | 103 VarMap::iterator found = live_vars_.find(var_id); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { | 242 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { |
243 if (iter->second.ref_count != 0 || | 243 if (iter->second.ref_count != 0 || |
244 iter->second.track_with_no_reference_count != 0) | 244 iter->second.track_with_no_reference_count != 0) |
245 return false; // Object still alive. | 245 return false; // Object still alive. |
246 iter->second.var->ResetVarID(); | 246 iter->second.var->ResetVarID(); |
247 live_vars_.erase(iter); | 247 live_vars_.erase(iter); |
248 return true; | 248 return true; |
249 } | 249 } |
250 | 250 |
251 } // namespace ppapi | 251 } // namespace ppapi |
OLD | NEW |