Index: ppapi/shared_impl/var_tracker.cc |
=================================================================== |
--- ppapi/shared_impl/var_tracker.cc (revision 186938) |
+++ ppapi/shared_impl/var_tracker.cc (working copy) |
@@ -27,27 +27,22 @@ |
track_with_no_reference_count(0) { |
} |
-VarTracker::VarTracker(ThreadMode thread_mode) : last_var_id_(0) { |
- if (thread_mode == SINGLE_THREADED) |
- thread_checker_.reset(new base::ThreadChecker); |
+VarTracker::VarTracker() : last_var_id_(0) { |
} |
VarTracker::~VarTracker() { |
} |
-void VarTracker::CheckThreadingPreconditions() const { |
- DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread()); |
+int32 VarTracker::AddVar(Var* var) { |
+ DCHECK(CalledOnValidThread()); |
ProxyLock::AssertAcquired(); |
-} |
-int32 VarTracker::AddVar(Var* var) { |
- CheckThreadingPreconditions(); |
- |
return AddVarInternal(var, ADD_VAR_TAKE_ONE_REFERENCE); |
} |
Var* VarTracker::GetVar(int32 var_id) const { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
VarMap::const_iterator result = live_vars_.find(var_id); |
if (result == live_vars_.end()) |
@@ -56,7 +51,8 @@ |
} |
Var* VarTracker::GetVar(const PP_Var& var) const { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
if (!IsVarTypeRefcounted(var.type)) |
return NULL; |
@@ -64,7 +60,8 @@ |
} |
bool VarTracker::AddRefVar(int32 var_id) { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR)) |
<< var_id << " is not a PP_Var ID."; |
@@ -89,7 +86,8 @@ |
} |
bool VarTracker::AddRefVar(const PP_Var& var) { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
if (!IsVarTypeRefcounted(var.type)) |
return false; |
@@ -97,7 +95,8 @@ |
} |
bool VarTracker::ReleaseVar(int32 var_id) { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR)) |
<< var_id << " is not a PP_Var ID."; |
@@ -128,7 +127,8 @@ |
} |
bool VarTracker::ReleaseVar(const PP_Var& var) { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
if (!IsVarTypeRefcounted(var.type)) |
return false; |
@@ -152,7 +152,8 @@ |
} |
int VarTracker::GetRefCountForObject(const PP_Var& plugin_object) { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
VarMap::iterator found = GetLiveVar(plugin_object); |
if (found == live_vars_.end()) |
@@ -162,7 +163,8 @@ |
int VarTracker::GetTrackedWithNoReferenceCountForObject( |
const PP_Var& plugin_object) { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
VarMap::iterator found = GetLiveVar(plugin_object); |
if (found == live_vars_.end()) |
@@ -184,7 +186,8 @@ |
} |
PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes) { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes)); |
if (!array_buffer) |
@@ -194,7 +197,8 @@ |
PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes, |
const void* data) { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
ArrayBufferVar* array_buffer = MakeArrayBufferVar(size_in_bytes, data); |
return array_buffer ? array_buffer->GetPPVar() : PP_MakeNull(); |
@@ -202,7 +206,8 @@ |
ArrayBufferVar* VarTracker::MakeArrayBufferVar(uint32 size_in_bytes, |
const void* data) { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
ArrayBufferVar* array_buffer(CreateArrayBuffer(size_in_bytes)); |
if (!array_buffer) |
@@ -212,7 +217,8 @@ |
} |
std::vector<PP_Var> VarTracker::GetLiveVars() { |
- CheckThreadingPreconditions(); |
+ DCHECK(CalledOnValidThread()); |
+ ProxyLock::AssertAcquired(); |
std::vector<PP_Var> var_vector; |
var_vector.reserve(live_vars_.size()); |