diff options
author | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 19:18:53 +0000 |
---|---|---|
committer | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 19:18:53 +0000 |
commit | 7d2e5f7627b05eda3ad483b5cd4d656121ade990 (patch) | |
tree | 23cf1f6999b4bc07113a5ac56a4bb474fd5c994d /base/supports_user_data.h | |
parent | d9263212549965ba7d6fb7d0eb570a361d2c0624 (diff) | |
download | chromium_src-7d2e5f7627b05eda3ad483b5cd4d656121ade990.zip chromium_src-7d2e5f7627b05eda3ad483b5cd4d656121ade990.tar.gz chromium_src-7d2e5f7627b05eda3ad483b5cd4d656121ade990.tar.bz2 |
SupportsUserData is not thread safe
Lets ensure none of its usages are unsafe.
BUG=
Review URL: https://chromiumcodereview.appspot.com/10919137
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155794 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/supports_user_data.h')
-rw-r--r-- | base/supports_user_data.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/base/supports_user_data.h b/base/supports_user_data.h index e663ed2..4c7cdca 100644 --- a/base/supports_user_data.h +++ b/base/supports_user_data.h @@ -10,6 +10,7 @@ #include "base/base_export.h" #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" +#include "base/threading/thread_checker.h" namespace base { @@ -35,6 +36,12 @@ class BASE_EXPORT SupportsUserData { void SetUserData(const void* key, Data* data); void RemoveUserData(const void* key); + // SupportsUserData is not thread-safe, and on debug build will assert it is + // only used on one thread. Calling this method allows the caller to hand + // the SupportsUserData instance across threads. Use only if you are taking + // full control of the synchronization of that hand over. + void DetachUserDataThread(); + protected: virtual ~SupportsUserData(); @@ -43,6 +50,8 @@ class BASE_EXPORT SupportsUserData { // Externally-defined data accessible by key. DataMap user_data_; + // Guards usage of |user_data_| + ThreadChecker thread_checker_; DISALLOW_COPY_AND_ASSIGN(SupportsUserData); }; |