Chromium Code Reviews| 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 |
| index e592742e6a348375a3d3de745b6be68d1c04a56d..ceb2adb018a829e22524e162329d33dbf855e6f1 100644 |
| --- a/base/threading/thread_id_name_manager.h |
| +++ b/base/threading/thread_id_name_manager.h |
| @@ -23,6 +23,9 @@ class BASE_EXPORT ThreadIdNameManager { |
| static const char* GetDefaultInternedString(); |
| + // Register the mapping between a thread |id| and |handle|. |
| + void RegisterThread(PlatformThreadHandle::Handle handle, PlatformThreadId id); |
| + |
| // Set the name for the given id. |
| void SetName(PlatformThreadId id, const char* name); |
| @@ -30,19 +33,31 @@ class BASE_EXPORT ThreadIdNameManager { |
| const char* GetName(PlatformThreadId id); |
| // Remove the name for the given id. |
| - void RemoveName(PlatformThreadId id); |
| + void RemoveName(PlatformThreadHandle::Handle handle, PlatformThreadId id); |
| private: |
| friend struct DefaultSingletonTraits<ThreadIdNameManager>; |
| + typedef std::map<PlatformThreadId, PlatformThreadHandle::Handle> |
| + ThreadIdToHandleMap; |
| + typedef std::map<PlatformThreadHandle::Handle, std::string*> |
| + ThreadHandleToInternedNameMap; |
| + typedef std::map<std::string, std::string*> NameToInternedNameMap; |
| + |
| ThreadIdNameManager(); |
| ~ThreadIdNameManager(); |
| - // lock_ protects both the thread_id_to_name_ and name_to_interned_name_ maps. |
| + // lock_ protects the name_to_interned_name_, thread_id_to_handle_ and |
| + // thread_handle_to_interned_name_ maps. |
| Lock lock_; |
| - std::map<PlatformThreadId, std::string*> thread_id_to_interned_name_; |
| - std::map<std::string, std::string*> name_to_interned_name_; |
| + NameToInternedNameMap name_to_interned_name_; |
| + ThreadIdToHandleMap thread_id_to_handle_; |
| + ThreadHandleToInternedNameMap thread_handle_to_interned_name_; |
| + |
| + // Treat the main process specially as it doesn't have a PlatformThreadHandle |
|
jar (doing other things)
2013/05/25 00:25:09
nit: period at end of sentence... and you might ha
dsinclair
2013/05/27 18:50:59
Done.
|
| + std::string* main_process_name_; |
| + PlatformThreadId main_process_id_; |
| DISALLOW_COPY_AND_ASSIGN(ThreadIdNameManager); |
| }; |