| Index: base/threading/thread_id_name_manager.cc
|
| diff --git a/base/threading/thread_id_name_manager.cc b/base/threading/thread_id_name_manager.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4374aa52bc153858656219e071aebb046d520d0e
|
| --- /dev/null
|
| +++ b/base/threading/thread_id_name_manager.cc
|
| @@ -0,0 +1,46 @@
|
| +// 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.
|
| +
|
| +#include "base/threading/thread_id_name_manager.h"
|
| +
|
| +#include "base/memory/singleton.h"
|
| +
|
| +namespace base {
|
| +
|
| +ThreadIdNameManager::ThreadIdNameManager() {
|
| +}
|
| +
|
| +ThreadIdNameManager::~ThreadIdNameManager() {
|
| +}
|
| +
|
| +ThreadIdNameManager* ThreadIdNameManager::GetInstance() {
|
| + return Singleton<ThreadIdNameManager>::get();
|
| +}
|
| +
|
| +bool ThreadIdNameManager::GetNameForId(PlatformThreadId id, std::string* name) {
|
| + if (name == NULL)
|
| + return false;
|
| +
|
| + base::AutoLock locked(lock_);
|
| +
|
| + std::map<PlatformThreadId, std::string>::const_iterator it;
|
| + it = id_to_name_.find(id);
|
| + if (it == id_to_name_.end())
|
| + return false;
|
| +
|
| + *name = it->second;
|
| + return true;
|
| +}
|
| +
|
| +void ThreadIdNameManager::SetNameForId(PlatformThreadId id, std::string name) {
|
| + base::AutoLock locked(lock_);
|
| + id_to_name_[id] = name;
|
| +}
|
| +
|
| +void ThreadIdNameManager::RemoveNameForId(PlatformThreadId id) {
|
| + base::AutoLock locked(lock_);
|
| + id_to_name_.erase(id);
|
| +}
|
| +
|
| +} // namespace base
|
|
|