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

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

Issue 12096107: Revert 180093 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 months 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/test_case.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string.h> 7 #include <string.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 DCHECK(CalledOnValidThread()); 179 DCHECK(CalledOnValidThread());
180 180
181 scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes)); 181 scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes));
182 if (!array_buffer) 182 if (!array_buffer)
183 return PP_MakeNull(); 183 return PP_MakeNull();
184 return array_buffer->GetPPVar(); 184 return array_buffer->GetPPVar();
185 } 185 }
186 186
187 PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes, 187 PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes,
188 const void* data) { 188 const void* data) {
189 ArrayBufferVar* array_buffer = MakeArrayBufferVar(size_in_bytes, data); 189 DCHECK(CalledOnValidThread());
190 return array_buffer ? array_buffer->GetPPVar() : PP_MakeNull();
191 }
192 190
193 ArrayBufferVar* VarTracker::MakeArrayBufferVar(uint32 size_in_bytes, 191 scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes));
194 const void* data) {
195 DCHECK(CalledOnValidThread());
196 ArrayBufferVar* array_buffer(CreateArrayBuffer(size_in_bytes));
197 if (!array_buffer) 192 if (!array_buffer)
198 return NULL; 193 return PP_MakeNull();
199 memcpy(array_buffer->Map(), data, size_in_bytes); 194 memcpy(array_buffer->Map(), data, size_in_bytes);
200 return array_buffer; 195 return array_buffer->GetPPVar();
201 } 196 }
202 197
203 std::vector<PP_Var> VarTracker::GetLiveVars() { 198 std::vector<PP_Var> VarTracker::GetLiveVars() {
204 DCHECK(CalledOnValidThread()); 199 DCHECK(CalledOnValidThread());
205 200
206 std::vector<PP_Var> var_vector; 201 std::vector<PP_Var> var_vector;
207 var_vector.reserve(live_vars_.size()); 202 var_vector.reserve(live_vars_.size());
208 for (VarMap::const_iterator iter = live_vars_.begin(); 203 for (VarMap::const_iterator iter = live_vars_.begin();
209 iter != live_vars_.end(); 204 iter != live_vars_.end();
210 ++iter) { 205 ++iter) {
(...skipping 14 matching lines...) Expand all
225 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { 220 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) {
226 if (iter->second.ref_count != 0 || 221 if (iter->second.ref_count != 0 ||
227 iter->second.track_with_no_reference_count != 0) 222 iter->second.track_with_no_reference_count != 0)
228 return false; // Object still alive. 223 return false; // Object still alive.
229 iter->second.var->ResetVarID(); 224 iter->second.var->ResetVarID();
230 live_vars_.erase(iter); 225 live_vars_.erase(iter);
231 return true; 226 return true;
232 } 227 }
233 228
234 } // namespace ppapi 229 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/var_tracker.h ('k') | ppapi/tests/test_case.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698