Index: base/threading/thread_id_name_manager.h |
diff --git a/base/threading/thread_id_name_manager.h b/base/threading/thread_id_name_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..79ad209cebf4d0ecce2be0399e5ffc62572d6b07 |
--- /dev/null |
+++ b/base/threading/thread_id_name_manager.h |
@@ -0,0 +1,44 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ |
+#define BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ |
+ |
+#include <map> |
+#include <string> |
+ |
+#include "base/base_export.h" |
+#include "base/basictypes.h" |
+#include "base/synchronization/lock.h" |
+#include "base/threading/platform_thread.h" |
+ |
+template <typename T> struct DefaultSingletonTraits; |
jonathan.backer
2012/12/05 20:06:12
Different traits define kAllowedToAccessOnNonjoina
dsinclair
2012/12/05 20:40:09
Switched to LeakySingletonTraits.
|
+ |
+namespace base { |
+ |
+class BASE_EXPORT ThreadIdNameManager { |
+ public: |
+ static ThreadIdNameManager* GetInstance(); |
+ |
+ bool GetNameForId(PlatformThreadId id, std::string* name); |
+ void SetNameForId(PlatformThreadId id, std::string name); |
+ void RemoveNameForId(PlatformThreadId id); |
+ |
+ private: |
+ friend struct DefaultSingletonTraits<ThreadIdNameManager>; |
+ |
+ ThreadIdNameManager(); |
+ ~ThreadIdNameManager(); |
+ |
+ // protectes id_to_name_ |
+ base::Lock lock_; |
+ |
+ std::map<PlatformThreadId, std::string> id_to_name_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ThreadIdNameManager); |
+}; |
+ |
+} // namespace base |
+ |
+#endif // BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ |