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


CrOS-Libchrome-Original-Commit: 7d2e5f7627b05eda3ad483b5cd4d656121ade990
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 @@
   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 @@
 
   // Externally-defined data accessible by key.
   DataMap user_data_;
+  // Guards usage of |user_data_|
+  ThreadChecker thread_checker_;
 
   DISALLOW_COPY_AND_ASSIGN(SupportsUserData);
 };