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

Unified Diff: base/threading/platform_thread_win.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: Store a version number for the current name for fast comparisons. 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 side-by-side diff with in-line comments
Download patch
Index: base/threading/platform_thread_win.cc
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index 82981adaf834b7a813cabf40756f4c2d59222ac5..5bd4439462e861761a933650262bfa1535805408 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -7,7 +7,7 @@
#include "base/debug/alias.h"
#include "base/debug/profiler.h"
#include "base/logging.h"
-#include "base/threading/thread_local.h"
+#include "base/threading/thread_id_name_manager.h"
#include "base/threading/thread_restrictions.h"
#include "base/tracked_objects.h"
@@ -17,8 +17,6 @@ namespace base {
namespace {
-static ThreadLocalPointer<char> current_thread_name;
-
// The information on how to set the thread name comes from
// a MSDN article: http://msdn2.microsoft.com/en-us/library/xcb2z8hs.aspx
const DWORD kVCThreadNameException = 0x406D1388;
@@ -116,7 +114,7 @@ void PlatformThread::Sleep(TimeDelta duration) {
// static
void PlatformThread::SetName(const char* name) {
- current_thread_name.Set(const_cast<char*>(name));
+ ThreadIdNameManager::GetInstance()->SetNameForId(CurrentId(), name);
// On Windows only, we don't need to tell the profiler about the "BrokerEvent"
// thread, as it exists only in the chrome.exe image, and never spawns or runs
@@ -139,7 +137,12 @@ void PlatformThread::SetName(const char* name) {
// static
const char* PlatformThread::GetName() {
- return current_thread_name.Get();
+ return ThreadIdNameManager::GetInstance()->GetNameForId(CurrentId());
+}
+
+// static
+uint32 PlatformThread::GetVersionForName() {
+ return ThreadIdNameManager::GetInstance()->GetVersionForName(CurrentId());
}
// static

Powered by Google App Engine
This is Rietveld 408576698