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

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: merge 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_tracker.h ('k') | ppapi/tests/all_c_includes.h » ('j') | 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 VarTracker::VarMap::iterator VarTracker::GetLiveVar(const PP_Var& var) { 132 VarTracker::VarMap::iterator VarTracker::GetLiveVar(const PP_Var& var) {
133 return live_vars_.find(static_cast<int32>(var.value.as_id)); 133 return live_vars_.find(static_cast<int32>(var.value.as_id));
134 } 134 }
135 135
136 VarTracker::VarMap::const_iterator VarTracker::GetLiveVar( 136 VarTracker::VarMap::const_iterator VarTracker::GetLiveVar(
137 const PP_Var& var) const { 137 const PP_Var& var) const {
138 return live_vars_.find(static_cast<int32>(var.value.as_id)); 138 return live_vars_.find(static_cast<int32>(var.value.as_id));
139 } 139 }
140 140
141 bool VarTracker::IsVarTypeRefcounted(PP_VarType type) const { 141 bool VarTracker::IsVarTypeRefcounted(PP_VarType type) const {
142 return type == PP_VARTYPE_STRING || type == PP_VARTYPE_OBJECT; 142 return type >= PP_VARTYPE_STRING;
143 }
144
145 PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes) {
146 scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes));
147 if (!array_buffer)
148 return PP_MakeNull();
149 return array_buffer->GetPPVar();
143 } 150 }
144 151
145 void VarTracker::TrackedObjectGettingOneRef(VarMap::const_iterator obj) { 152 void VarTracker::TrackedObjectGettingOneRef(VarMap::const_iterator obj) {
146 // Anybody using tracked objects should override this. 153 // Anybody using tracked objects should override this.
147 NOTREACHED(); 154 NOTREACHED();
148 } 155 }
149 156
150 void VarTracker::ObjectGettingZeroRef(VarMap::iterator iter) { 157 void VarTracker::ObjectGettingZeroRef(VarMap::iterator iter) {
151 DeleteObjectInfoIfNecessary(iter); 158 DeleteObjectInfoIfNecessary(iter);
152 } 159 }
153 160
154 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { 161 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) {
155 if (iter->second.ref_count != 0 || 162 if (iter->second.ref_count != 0 ||
156 iter->second.track_with_no_reference_count != 0) 163 iter->second.track_with_no_reference_count != 0)
157 return false; // Object still alive. 164 return false; // Object still alive.
158 live_vars_.erase(iter); 165 live_vars_.erase(iter);
159 return true; 166 return true;
160 } 167 }
161 168
162 } // namespace ppapi 169 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/var_tracker.h ('k') | ppapi/tests/all_c_includes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698