Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ | |
| 6 #define BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/base_export.h" | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/synchronization/lock.h" | |
| 14 #include "base/threading/platform_thread.h" | |
| 15 | |
| 16 template <typename T> struct DefaultSingletonTraits; | |
| 17 | |
| 18 namespace base { | |
| 19 | |
| 20 class BASE_EXPORT ThreadIdNameManager { | |
| 21 public: | |
| 22 static ThreadIdNameManager* GetInstance(); | |
| 23 | |
| 24 static const char* GetDefaultInternedString(); | |
| 25 | |
| 26 // Set the name for the given id. | |
| 27 void SetName(PlatformThreadId id, const char* name); | |
| 28 | |
| 29 // Get the name for the given id. | |
| 30 const char* GetName(PlatformThreadId id); | |
| 31 | |
| 32 // Remove the name for the given id. | |
| 33 void RemoveName(PlatformThreadId id); | |
| 34 | |
| 35 private: | |
| 36 friend struct DefaultSingletonTraits<ThreadIdNameManager>; | |
| 37 | |
| 38 ThreadIdNameManager(); | |
| 39 ~ThreadIdNameManager(); | |
| 40 | |
| 41 // protects id_to_name_. | |
|
jar (doing other things)
2013/01/25 03:13:25
nit: Make a full sentence, such as:
lock_ protect
dsinclair
2013/01/25 14:54:43
Done.
| |
| 42 Lock lock_; | |
| 43 | |
| 44 std::map<PlatformThreadId, std::string*> thread_id_to_interned_name_; | |
| 45 std::map<std::string, std::string*> name_to_interned_name_; | |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(ThreadIdNameManager); | |
| 48 }; | |
| 49 | |
| 50 } // namespace base | |
| 51 | |
| 52 #endif // BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ | |
| OLD | NEW |