diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 19:18:41 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 19:18:41 +0000 |
commit | 460d2fd0876fddb9e6a2a17cba9c70beb93dfa03 (patch) | |
tree | 4e0cf902613ff0a64a7fa69959e48a0160bbf2f2 /ppapi/shared_impl/resource_tracker.cc | |
parent | b26ac3b182b8c63192ad1f8e221ceac3fe5927be (diff) | |
download | chromium_src-460d2fd0876fddb9e6a2a17cba9c70beb93dfa03.zip chromium_src-460d2fd0876fddb9e6a2a17cba9c70beb93dfa03.tar.gz chromium_src-460d2fd0876fddb9e6a2a17cba9c70beb93dfa03.tar.bz2 |
PPAPI: Remove threading options; it's always on
This also re-enables thread checking for the host side resource and var trackers. Before, checking was disabled everywhere.
BUG=159240,92909
Committed: r186925
Reverted: r186939 due to build errors
Committed: r187340
Committed: r187427
Reverted: r187668 due to a failing check in Canary, which was fixed here: r187681
Committed: r189518
Reverted: r189682, due to regression in Kraken (see crbug.com/222741)
Review URL: https://chromiumcodereview.appspot.com/12378050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl/resource_tracker.cc')
-rw-r--r-- | ppapi/shared_impl/resource_tracker.cc | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/ppapi/shared_impl/resource_tracker.cc b/ppapi/shared_impl/resource_tracker.cc index f7e22eb..275a1e5 100644 --- a/ppapi/shared_impl/resource_tracker.cc +++ b/ppapi/shared_impl/resource_tracker.cc @@ -15,17 +15,25 @@ namespace ppapi { -ResourceTracker::ResourceTracker() +ResourceTracker::ResourceTracker(ThreadMode thread_mode) : last_resource_value_(0), ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { + if (thread_mode == SINGLE_THREADED) + thread_checker_.reset(new base::ThreadChecker); } ResourceTracker::~ResourceTracker() { } -Resource* ResourceTracker::GetResource(PP_Resource res) const { - CHECK(thread_checker_.CalledOnValidThread()); +void ResourceTracker::CheckThreadingPreconditions() const { + DCHECK(!thread_checker_ || thread_checker_->CalledOnValidThread()); +#ifndef NDEBUG ProxyLock::AssertAcquired(); +#endif +} + +Resource* ResourceTracker::GetResource(PP_Resource res) const { + CheckThreadingPreconditions(); ResourceMap::const_iterator i = live_resources_.find(res); if (i == live_resources_.end()) return NULL; @@ -33,7 +41,7 @@ Resource* ResourceTracker::GetResource(PP_Resource res) const { } void ResourceTracker::AddRefResource(PP_Resource res) { - CHECK(thread_checker_.CalledOnValidThread()); + CheckThreadingPreconditions(); DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) << res << " is not a PP_Resource."; ResourceMap::iterator i = live_resources_.find(res); @@ -55,7 +63,7 @@ void ResourceTracker::AddRefResource(PP_Resource res) { } void ResourceTracker::ReleaseResource(PP_Resource res) { - CHECK(thread_checker_.CalledOnValidThread()); + CheckThreadingPreconditions(); DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) << res << " is not a PP_Resource."; ResourceMap::iterator i = live_resources_.find(res); @@ -86,7 +94,7 @@ void ResourceTracker::ReleaseResourceSoon(PP_Resource res) { } void ResourceTracker::DidCreateInstance(PP_Instance instance) { - CHECK(thread_checker_.CalledOnValidThread()); + CheckThreadingPreconditions(); // Due to the infrastructure of some tests, the instance is registered // twice in a few cases. It would be nice not to do that and assert here // instead. @@ -96,7 +104,7 @@ void ResourceTracker::DidCreateInstance(PP_Instance instance) { } void ResourceTracker::DidDeleteInstance(PP_Instance instance) { - CHECK(thread_checker_.CalledOnValidThread()); + CheckThreadingPreconditions(); InstanceMap::iterator found_instance = instance_map_.find(instance); // Due to the infrastructure of some tests, the instance is unregistered @@ -151,7 +159,7 @@ void ResourceTracker::DidDeleteInstance(PP_Instance instance) { } int ResourceTracker::GetLiveObjectsForInstance(PP_Instance instance) const { - CHECK(thread_checker_.CalledOnValidThread()); + CheckThreadingPreconditions(); InstanceMap::const_iterator found = instance_map_.find(instance); if (found == instance_map_.end()) return 0; @@ -159,7 +167,7 @@ int ResourceTracker::GetLiveObjectsForInstance(PP_Instance instance) const { } PP_Resource ResourceTracker::AddResource(Resource* object) { - CHECK(thread_checker_.CalledOnValidThread()); + CheckThreadingPreconditions(); // If the plugin manages to create too many resources, don't do crazy stuff. if (last_resource_value_ == kMaxPPId) return 0; @@ -191,7 +199,7 @@ PP_Resource ResourceTracker::AddResource(Resource* object) { } void ResourceTracker::RemoveResource(Resource* object) { - CHECK(thread_checker_.CalledOnValidThread()); + CheckThreadingPreconditions(); PP_Resource pp_resource = object->pp_resource(); InstanceMap::iterator found = instance_map_.find(object->pp_instance()); if (found != instance_map_.end()) |