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 #include "base/threading/thread_id_name_manager.h" | |
| 6 | |
| 7 #include "base/memory/singleton.h" | |
| 8 | |
| 9 namespace base { | |
| 10 | |
| 11 ThreadIdNameManager::ThreadIdNameManager() { | |
| 12 } | |
| 13 | |
| 14 ThreadIdNameManager::~ThreadIdNameManager() { | |
| 15 } | |
| 16 | |
| 17 ThreadIdNameManager* ThreadIdNameManager::GetInstance() { | |
| 18 return Singleton<ThreadIdNameManager, | |
| 19 LeakySingletonTraits<ThreadIdNameManager> >::get(); | |
| 20 } | |
| 21 | |
| 22 const char* ThreadIdNameManager::GetNameForId(PlatformThreadId id) { | |
| 23 base::AutoLock locked(lock_); | |
| 24 | |
| 25 std::map<PlatformThreadId, const char*>::const_iterator it; | |
| 26 it = id_to_name_.find(id); | |
| 27 if (it == id_to_name_.end()) | |
| 28 return NULL; | |
| 29 return it->second; | |
| 30 } | |
| 31 | |
| 32 void ThreadIdNameManager::SetNameForId(PlatformThreadId id, const char* name) { | |
| 33 base::AutoLock locked(lock_); | |
| 34 id_to_name_[id] = name; | |
|
jar (doing other things)
2012/12/06 20:54:37
nit: can/should we have a DCHECK here to verify th
dsinclair
2012/12/10 16:24:36
It seems that being able to SetName multiple times
| |
| 35 } | |
| 36 | |
| 37 void ThreadIdNameManager::RemoveNameForId(PlatformThreadId id) { | |
| 38 base::AutoLock locked(lock_); | |
| 39 id_to_name_.erase(id); | |
|
jar (doing other things)
2012/12/06 20:54:37
nit: can/should we have a DCHECK here to verify th
dsinclair
2012/12/10 16:24:36
It's possible the name wouldn't be set, but in tha
| |
| 40 } | |
| 41 | |
| 42 } // namespace base | |
| OLD | NEW |