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

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

Issue 13887007: Introduce RawVarData and associated classes for serializing PP_Vars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 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') | 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) 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 int VarTracker::GetTrackedWithNoReferenceCountForObject( 167 int VarTracker::GetTrackedWithNoReferenceCountForObject(
168 const PP_Var& plugin_object) { 168 const PP_Var& plugin_object) {
169 CheckThreadingPreconditions(); 169 CheckThreadingPreconditions();
170 170
171 VarMap::iterator found = GetLiveVar(plugin_object); 171 VarMap::iterator found = GetLiveVar(plugin_object);
172 if (found == live_vars_.end()) 172 if (found == live_vars_.end())
173 return -1; 173 return -1;
174 return found->second.track_with_no_reference_count; 174 return found->second.track_with_no_reference_count;
175 } 175 }
176 176
177 // static
178 bool VarTracker::IsVarTypeRefcounted(PP_VarType type) {
179 return type >= PP_VARTYPE_STRING;
180 }
181
177 VarTracker::VarMap::iterator VarTracker::GetLiveVar(const PP_Var& var) { 182 VarTracker::VarMap::iterator VarTracker::GetLiveVar(const PP_Var& var) {
178 return live_vars_.find(static_cast<int32>(var.value.as_id)); 183 return live_vars_.find(static_cast<int32>(var.value.as_id));
179 } 184 }
180 185
181 VarTracker::VarMap::const_iterator VarTracker::GetLiveVar( 186 VarTracker::VarMap::const_iterator VarTracker::GetLiveVar(
182 const PP_Var& var) const { 187 const PP_Var& var) const {
183 return live_vars_.find(static_cast<int32>(var.value.as_id)); 188 return live_vars_.find(static_cast<int32>(var.value.as_id));
184 } 189 }
185 190
186 bool VarTracker::IsVarTypeRefcounted(PP_VarType type) const {
187 return type >= PP_VARTYPE_STRING;
188 }
189
190 PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes) { 191 PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes) {
191 CheckThreadingPreconditions(); 192 CheckThreadingPreconditions();
192 193
193 scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes)); 194 scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes));
194 if (!array_buffer) 195 if (!array_buffer)
195 return PP_MakeNull(); 196 return PP_MakeNull();
196 return array_buffer->GetPPVar(); 197 return array_buffer->GetPPVar();
197 } 198 }
198 199
199 PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes, 200 PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) { 252 bool VarTracker::DeleteObjectInfoIfNecessary(VarMap::iterator iter) {
252 if (iter->second.ref_count != 0 || 253 if (iter->second.ref_count != 0 ||
253 iter->second.track_with_no_reference_count != 0) 254 iter->second.track_with_no_reference_count != 0)
254 return false; // Object still alive. 255 return false; // Object still alive.
255 iter->second.var->ResetVarID(); 256 iter->second.var->ResetVarID();
256 live_vars_.erase(iter); 257 live_vars_.erase(iter);
257 return true; 258 return true;
258 } 259 }
259 260
260 } // namespace ppapi 261 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/var_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698