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

Unified Diff: base/supports_user_data.h

Issue 10919137: SupportsUserData is not thread safe (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed indexeddb test Created 8 years, 3 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 | « no previous file | base/supports_user_data.cc » ('j') | base/supports_user_data.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/supports_user_data.h
diff --git a/base/supports_user_data.h b/base/supports_user_data.h
index e663ed2ed5c8793741b871c6110dca986160762b..4c7cdcad26202bb5577f31013a01f1a0587afa36 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);
};
« no previous file with comments | « no previous file | base/supports_user_data.cc » ('j') | base/supports_user_data.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698