| 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/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" |
| 11 #include "ppapi/shared_impl/var.h" | 11 #include "ppapi/shared_impl/var.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 live_vars_.insert(std::make_pair(new_id, | 122 live_vars_.insert(std::make_pair(new_id, |
| 123 VarInfo(var, mode == ADD_VAR_TAKE_ONE_REFERENCE ? 1 : 0))); | 123 VarInfo(var, mode == ADD_VAR_TAKE_ONE_REFERENCE ? 1 : 0))); |
| 124 | 124 |
| 125 return new_id; | 125 return new_id; |
| 126 } | 126 } |
| 127 | 127 |
| 128 VarTracker::VarMap::iterator VarTracker::GetLiveVar(int32 id) { | 128 VarTracker::VarMap::iterator VarTracker::GetLiveVar(int32 id) { |
| 129 return live_vars_.find(id); | 129 return live_vars_.find(id); |
| 130 } | 130 } |
| 131 | 131 |
| 132 int VarTracker::GetRefCountForObject(const PP_Var& plugin_object) { | |
| 133 VarMap::iterator found = GetLiveVar(plugin_object); | |
| 134 if (found == live_vars_.end()) | |
| 135 return -1; | |
| 136 return found->second.ref_count; | |
| 137 } | |
| 138 | |
| 139 int VarTracker::GetTrackedWithNoReferenceCountForObject( | |
| 140 const PP_Var& plugin_object) { | |
| 141 VarMap::iterator found = GetLiveVar(plugin_object); | |
| 142 if (found == live_vars_.end()) | |
| 143 return -1; | |
| 144 return found->second.track_with_no_reference_count; | |
| 145 } | |
| 146 | |
| 147 VarTracker::VarMap::iterator VarTracker::GetLiveVar(const PP_Var& var) { | 132 VarTracker::VarMap::iterator VarTracker::GetLiveVar(const PP_Var& var) { |
| 148 return live_vars_.find(static_cast<int32>(var.value.as_id)); | 133 return live_vars_.find(static_cast<int32>(var.value.as_id)); |
| 149 } | 134 } |
| 150 | 135 |
| 151 VarTracker::VarMap::const_iterator VarTracker::GetLiveVar( | 136 VarTracker::VarMap::const_iterator VarTracker::GetLiveVar( |
| 152 const PP_Var& var) const { | 137 const PP_Var& var) const { |
| 153 return live_vars_.find(static_cast<int32>(var.value.as_id)); | 138 return live_vars_.find(static_cast<int32>(var.value.as_id)); |
| 154 } | 139 } |
| 155 | 140 |
| 156 bool VarTracker::IsVarTypeRefcounted(PP_VarType type) const { | 141 bool VarTracker::IsVarTypeRefcounted(PP_VarType type) const { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 187 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { | 172 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { |
| 188 if (iter->second.ref_count != 0 || | 173 if (iter->second.ref_count != 0 || |
| 189 iter->second.track_with_no_reference_count != 0) | 174 iter->second.track_with_no_reference_count != 0) |
| 190 return false; // Object still alive. | 175 return false; // Object still alive. |
| 191 iter->second.var->ResetVarID(); | 176 iter->second.var->ResetVarID(); |
| 192 live_vars_.erase(iter); | 177 live_vars_.erase(iter); |
| 193 return true; | 178 return true; |
| 194 } | 179 } |
| 195 | 180 |
| 196 } // namespace ppapi | 181 } // namespace ppapi |
| OLD | NEW |