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

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

Issue 8930010: Implement in-process PPB_VarArrayBuffer_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some pre-review cleanup. 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
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 VarTracker::VarMap::iterator VarTracker::GetLiveVar(const PP_Var& var) { 131 VarTracker::VarMap::iterator VarTracker::GetLiveVar(const PP_Var& var) {
132 return live_vars_.find(static_cast<int32>(var.value.as_id)); 132 return live_vars_.find(static_cast<int32>(var.value.as_id));
133 } 133 }
134 134
135 VarTracker::VarMap::const_iterator VarTracker::GetLiveVar( 135 VarTracker::VarMap::const_iterator VarTracker::GetLiveVar(
136 const PP_Var& var) const { 136 const PP_Var& var) const {
137 return live_vars_.find(static_cast<int32>(var.value.as_id)); 137 return live_vars_.find(static_cast<int32>(var.value.as_id));
138 } 138 }
139 139
140 bool VarTracker::IsVarTypeRefcounted(PP_VarType type) const { 140 bool VarTracker::IsVarTypeRefcounted(PP_VarType type) const {
141 return type == PP_VARTYPE_STRING || type == PP_VARTYPE_OBJECT; 141 return type >= PP_VARTYPE_STRING;
142 }
143
144 PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes) {
145 scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes));
146 if (!array_buffer)
147 return PP_MakeNull();
148 return array_buffer->GetPPVar();
142 } 149 }
143 150
144 void VarTracker::TrackedObjectGettingOneRef(VarMap::const_iterator obj) { 151 void VarTracker::TrackedObjectGettingOneRef(VarMap::const_iterator obj) {
145 // Anybody using tracked objects should override this. 152 // Anybody using tracked objects should override this.
146 NOTREACHED(); 153 NOTREACHED();
147 } 154 }
148 155
149 void VarTracker::ObjectGettingZeroRef(VarMap::iterator iter) { 156 void VarTracker::ObjectGettingZeroRef(VarMap::iterator iter) {
150 DeleteObjectInfoIfNecessary(iter); 157 DeleteObjectInfoIfNecessary(iter);
151 } 158 }
152 159
153 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { 160 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) {
154 if (iter->second.ref_count != 0 || 161 if (iter->second.ref_count != 0 ||
155 iter->second.track_with_no_reference_count != 0) 162 iter->second.track_with_no_reference_count != 0)
156 return false; // Object still alive. 163 return false; // Object still alive.
157 live_vars_.erase(iter); 164 live_vars_.erase(iter);
158 return true; 165 return true;
159 } 166 }
160 167
161 } // namespace ppapi 168 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698