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

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

Issue 8872065: Pepper: Var keeps invalid var_id if VarTracker release it and there is another reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove redundant comma Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/shared_impl/var.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) 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
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();
103 live_vars_.erase(found); 104 live_vars_.erase(found);
104 } 105 }
105 } 106 }
106 return true; 107 return true;
107 } 108 }
108 109
109 bool VarTracker::ReleaseVar(const PP_Var& var) { 110 bool VarTracker::ReleaseVar(const PP_Var& var) {
110 if (!IsVarTypeRefcounted(var.type)) 111 if (!IsVarTypeRefcounted(var.type))
111 return false; 112 return false;
112 return ReleaseVar(static_cast<int32>(var.value.as_id)); 113 return ReleaseVar(static_cast<int32>(var.value.as_id));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 153
153 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { 154 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) {
154 if (iter->second.ref_count != 0 || 155 if (iter->second.ref_count != 0 ||
155 iter->second.track_with_no_reference_count != 0) 156 iter->second.track_with_no_reference_count != 0)
156 return false; // Object still alive. 157 return false; // Object still alive.
157 live_vars_.erase(iter); 158 live_vars_.erase(iter);
158 return true; 159 return true;
159 } 160 }
160 161
161 } // namespace ppapi 162 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/var.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698