diff options
author | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-06 22:03:27 +0000 |
---|---|---|
committer | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-06 22:03:27 +0000 |
commit | 97f79ec035e4c5f81fa4c916e8fda12de50d0a9f (patch) | |
tree | 2fd3583a1933197664281f93424278d6db6c3400 /ppapi/shared_impl/resource_tracker.h | |
parent | 44b79c2ce1a7adae7762014212155bb7b742cc92 (diff) | |
download | chromium_src-97f79ec035e4c5f81fa4c916e8fda12de50d0a9f.zip chromium_src-97f79ec035e4c5f81fa4c916e8fda12de50d0a9f.tar.gz chromium_src-97f79ec035e4c5f81fa4c916e8fda12de50d0a9f.tar.bz2 |
Add CHECKs to ensure that PPAPI resources are created on the right thread
These CHECKs could be converted to DCHECKs at some point. But we should get a
clear idea of how often this is happening and what issues it is responsible
for first.
BUG=146415,92909
TEST=Ran test case in http://code.google.com/p/chromium/issues/detail?id=143183
and checked that the CHECK fired.
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/10912086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl/resource_tracker.h')
-rw-r--r-- | ppapi/shared_impl/resource_tracker.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ppapi/shared_impl/resource_tracker.h b/ppapi/shared_impl/resource_tracker.h index 1c46bf5..2f1c54e 100644 --- a/ppapi/shared_impl/resource_tracker.h +++ b/ppapi/shared_impl/resource_tracker.h @@ -11,6 +11,8 @@ #include "base/hash_tables.h" #include "base/memory/linked_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" +#include "base/threading/thread_checker_impl.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/shared_impl/ppapi_shared_export.h" @@ -63,11 +65,11 @@ class PPAPI_SHARED_EXPORT ResourceTracker { // the given resource. It's called from the resource destructor. virtual void RemoveResource(Resource* object); + private: // Calls LastPluginRefWasDeleted on the given resource object and cancels // pending callbacks for the resource. void LastPluginRefWasDeleted(Resource* object); - private: typedef std::set<PP_Resource> ResourceSet; struct InstanceData { @@ -96,6 +98,20 @@ class PPAPI_SHARED_EXPORT ResourceTracker { base::WeakPtrFactory<ResourceTracker> weak_ptr_factory_; + // TODO(raymes): We won't need to do thread checks once pepper calls are + // allowed off of the main thread. + // See http://code.google.com/p/chromium/issues/detail?id=92909. +#ifdef ENABLE_PEPPER_THREADING + base::ThreadCheckerDoNothing thread_checker_; +#else + // TODO(raymes): We've seen plugins (Flash) creating resources from random + // threads. Let's always crash for now in this case. Once we have a handle + // over how common this is, we can change ThreadCheckerImpl->ThreadChecker + // so that we only crash in debug mode. See + // https://code.google.com/p/chromium/issues/detail?id=146415. + base::ThreadCheckerImpl thread_checker_; +#endif + DISALLOW_COPY_AND_ASSIGN(ResourceTracker); }; |