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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b5f1682ae29b8aeba0938b831a1de8c10899bbc0 |
| --- /dev/null |
| +++ b/base/threading/thread_id_name_manager.h |
| @@ -0,0 +1,63 @@ |
| +// 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. |
| + |
| +#ifndef BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ |
| +#define BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/base_export.h" |
| +#include "base/basictypes.h" |
| +#include "base/synchronization/lock.h" |
| +#include "base/threading/platform_thread.h" |
| + |
| +template <typename T> struct DefaultSingletonTraits; |
| + |
| +namespace base { |
| + |
| +typedef int InternedString; |
| +BASE_EXPORT extern const base::InternedString kDefaultInternedString; |
| + |
| +class BASE_EXPORT ThreadIdNameManager { |
| + public: |
| + |
|
jar (doing other things)
2013/01/17 23:18:39
nit: remove blank line
dsinclair
2013/01/21 19:14:18
Done.
|
| + static ThreadIdNameManager* GetInstance(); |
| + |
| + // Set the name for the given id. |
| + void SetNameForId(PlatformThreadId id, const char* name); |
| + |
| + // Get the name for the given id. |
| + const char* GetNameForId(PlatformThreadId id); |
|
jar (doing other things)
2013/01/17 23:18:39
Why do we have a getter that gets the char* for t
dsinclair
2013/01/21 19:14:18
Done.
Lost sight of the forest because of the tre
|
| + |
| + // Remove the name for the given id. |
| + void RemoveNameForId(PlatformThreadId id); |
| + |
| + // Retrieve the interned name for this thread. |
| + InternedString GetInternedName(PlatformThreadId id); |
| + |
| + // Retrieve the string value for the interned thread name. |
| + const char* GetInternedStringValue(InternedString str); |
| + |
| + private: |
| + friend struct DefaultSingletonTraits<ThreadIdNameManager>; |
| + |
| + ThreadIdNameManager(); |
| + ~ThreadIdNameManager(); |
| + |
| + // protectes id_to_name_ |
| + base::Lock lock_; |
| + |
| + std::map<PlatformThreadId, base::InternedString> id_to_interned_name_; |
|
jar (doing other things)
2013/01/17 23:18:39
nit: remove "base::"
do this througout this heade
dsinclair
2013/01/21 19:14:18
Done.
|
| + std::map<base::InternedString, std::string> interned_name_to_name_; |
| + std::map<std::string, base::InternedString> name_to_interned_name_; |
|
jar (doing other things)
2013/01/17 23:18:39
nit: remove "base::"
dsinclair
2013/01/21 19:14:18
Done.
|
| + |
| + base::InternedString current_interned_name_; |
|
jar (doing other things)
2013/01/17 23:18:39
Why not use something like interned_name_to_name_.
dsinclair
2013/01/21 19:14:18
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(ThreadIdNameManager); |
| +}; |
| + |
| +} // namespace base |
| + |
| +#endif // BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ |