Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: base/threading/thread_id_name_manager.cc

Issue 11438022: Add ability to retrieve a thread_name given a thread_id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move the set to PlatformThread::SetName so we catch any name changes. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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>::get();
19 }
20
21 bool ThreadIdNameManager::GetNameForId(PlatformThreadId id, std::string* name) {
22 if (name == NULL)
23 return false;
24
25 base::AutoLock locked(lock_);
26
27 std::map<PlatformThreadId, std::string>::const_iterator it;
28 it = id_to_name_.find(id);
29 if (it == id_to_name_.end())
30 return false;
31
32 *name = it->second;
33 return true;
34 }
35
36 void ThreadIdNameManager::SetNameForId(PlatformThreadId id, std::string name) {
37 base::AutoLock locked(lock_);
38 id_to_name_[id] = name;
39 }
40
41 void ThreadIdNameManager::RemoveNameForId(PlatformThreadId id) {
42 base::AutoLock locked(lock_);
43 id_to_name_.erase(id);
44 }
45
46 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698