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

Unified Diff: ppapi/shared_impl/var_tracker.cc

Issue 12378050: PPAPI: Remove threading options; it's always on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PDFResource unit test Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/shared_impl/var_tracker.h ('k') | ppapi/tests/test_case.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/var_tracker.cc
diff --git a/ppapi/shared_impl/var_tracker.cc b/ppapi/shared_impl/var_tracker.cc
index 434121ecbfa64b29b627e2d92f69acb17d99437e..951577cacaab8dd2895a2b322d508e044dc41a77 100644
--- a/ppapi/shared_impl/var_tracker.cc
+++ b/ppapi/shared_impl/var_tracker.cc
@@ -29,22 +29,29 @@ VarTracker::VarInfo::VarInfo(Var* v, int input_ref_count)
track_with_no_reference_count(0) {
}
-VarTracker::VarTracker() : last_var_id_(0) {
+VarTracker::VarTracker(ThreadMode thread_mode) : last_var_id_(0) {
+ if (thread_mode == SINGLE_THREADED)
+ thread_checker_.reset(new base::ThreadChecker);
}
VarTracker::~VarTracker() {
}
-int32 VarTracker::AddVar(Var* var) {
- DCHECK(CalledOnValidThread());
+void VarTracker::CheckThreadingPreconditions() const {
+ DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread());
+#ifndef NDEBUG
ProxyLock::AssertAcquired();
+#endif
+}
+
+int32 VarTracker::AddVar(Var* var) {
+ CheckThreadingPreconditions();
return AddVarInternal(var, ADD_VAR_TAKE_ONE_REFERENCE);
}
Var* VarTracker::GetVar(int32 var_id) const {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
VarMap::const_iterator result = live_vars_.find(var_id);
if (result == live_vars_.end())
@@ -53,8 +60,7 @@ Var* VarTracker::GetVar(int32 var_id) const {
}
Var* VarTracker::GetVar(const PP_Var& var) const {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
if (!IsVarTypeRefcounted(var.type))
return NULL;
@@ -62,8 +68,7 @@ Var* VarTracker::GetVar(const PP_Var& var) const {
}
bool VarTracker::AddRefVar(int32 var_id) {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR))
<< var_id << " is not a PP_Var ID.";
@@ -88,8 +93,7 @@ bool VarTracker::AddRefVar(int32 var_id) {
}
bool VarTracker::AddRefVar(const PP_Var& var) {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
if (!IsVarTypeRefcounted(var.type))
return true;
@@ -97,8 +101,7 @@ bool VarTracker::AddRefVar(const PP_Var& var) {
}
bool VarTracker::ReleaseVar(int32 var_id) {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR))
<< var_id << " is not a PP_Var ID.";
@@ -129,8 +132,7 @@ bool VarTracker::ReleaseVar(int32 var_id) {
}
bool VarTracker::ReleaseVar(const PP_Var& var) {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
if (!IsVarTypeRefcounted(var.type))
return false;
@@ -154,8 +156,7 @@ VarTracker::VarMap::iterator VarTracker::GetLiveVar(int32 id) {
}
int VarTracker::GetRefCountForObject(const PP_Var& plugin_object) {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
VarMap::iterator found = GetLiveVar(plugin_object);
if (found == live_vars_.end())
@@ -165,8 +166,7 @@ int VarTracker::GetRefCountForObject(const PP_Var& plugin_object) {
int VarTracker::GetTrackedWithNoReferenceCountForObject(
const PP_Var& plugin_object) {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
VarMap::iterator found = GetLiveVar(plugin_object);
if (found == live_vars_.end())
@@ -188,8 +188,7 @@ bool VarTracker::IsVarTypeRefcounted(PP_VarType type) const {
}
PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes) {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
scoped_refptr<ArrayBufferVar> array_buffer(CreateArrayBuffer(size_in_bytes));
if (!array_buffer)
@@ -199,8 +198,7 @@ PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes) {
PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes,
const void* data) {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
ArrayBufferVar* array_buffer = MakeArrayBufferVar(size_in_bytes, data);
return array_buffer ? array_buffer->GetPPVar() : PP_MakeNull();
@@ -208,8 +206,7 @@ PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes,
ArrayBufferVar* VarTracker::MakeArrayBufferVar(uint32 size_in_bytes,
const void* data) {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
ArrayBufferVar* array_buffer(CreateArrayBuffer(size_in_bytes));
if (!array_buffer)
@@ -220,7 +217,7 @@ ArrayBufferVar* VarTracker::MakeArrayBufferVar(uint32 size_in_bytes,
PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes,
base::SharedMemoryHandle handle) {
- DCHECK(CalledOnValidThread());
+ CheckThreadingPreconditions();
scoped_refptr<ArrayBufferVar> array_buffer(
CreateShmArrayBuffer(size_in_bytes, handle));
@@ -230,8 +227,7 @@ PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes,
}
std::vector<PP_Var> VarTracker::GetLiveVars() {
- DCHECK(CalledOnValidThread());
- ProxyLock::AssertAcquired();
+ CheckThreadingPreconditions();
std::vector<PP_Var> var_vector;
var_vector.reserve(live_vars_.size());
« 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