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/shared_impl/var_tracker.h" | 5 #include "ppapi/shared_impl/var_tracker.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ppapi/shared_impl/id_assignment.h" | 10 #include "ppapi/shared_impl/id_assignment.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 info.ref_count--; | 93 info.ref_count--; |
94 | 94 |
95 if (info.ref_count == 0) { | 95 if (info.ref_count == 0) { |
96 if (info.var->GetType() == PP_VARTYPE_OBJECT) { | 96 if (info.var->GetType() == PP_VARTYPE_OBJECT) { |
97 // Objects have special requirements and may not necessarily be released | 97 // Objects have special requirements and may not necessarily be released |
98 // when the refcount goes to 0. | 98 // when the refcount goes to 0. |
99 ObjectGettingZeroRef(found); | 99 ObjectGettingZeroRef(found); |
100 } else { | 100 } else { |
101 // All other var types can just be released. | 101 // All other var types can just be released. |
102 DCHECK(info.track_with_no_reference_count == 0); | 102 DCHECK(info.track_with_no_reference_count == 0); |
103 info.var->ResetVarID(); | |
104 live_vars_.erase(found); | 103 live_vars_.erase(found); |
105 } | 104 } |
106 } | 105 } |
107 return true; | 106 return true; |
108 } | 107 } |
109 | 108 |
110 bool VarTracker::ReleaseVar(const PP_Var& var) { | 109 bool VarTracker::ReleaseVar(const PP_Var& var) { |
111 if (!IsVarTypeRefcounted(var.type)) | 110 if (!IsVarTypeRefcounted(var.type)) |
112 return false; | 111 return false; |
113 return ReleaseVar(static_cast<int32>(var.value.as_id)); | 112 return ReleaseVar(static_cast<int32>(var.value.as_id)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 152 |
154 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { | 153 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { |
155 if (iter->second.ref_count != 0 || | 154 if (iter->second.ref_count != 0 || |
156 iter->second.track_with_no_reference_count != 0) | 155 iter->second.track_with_no_reference_count != 0) |
157 return false; // Object still alive. | 156 return false; // Object still alive. |
158 live_vars_.erase(iter); | 157 live_vars_.erase(iter); |
159 return true; | 158 return true; |
160 } | 159 } |
161 | 160 |
162 } // namespace ppapi | 161 } // namespace ppapi |
OLD | NEW |