Index: base/threading/platform_thread_win.cc |
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc |
index 56d73811c0fc5fd63e0f6d76a606306d4ad4669b..e2d90d8eccce67674247cecdfd8b9dac7224844c 100644 |
--- a/base/threading/platform_thread_win.cc |
+++ b/base/threading/platform_thread_win.cc |
@@ -5,13 +5,17 @@ |
#include "base/threading/platform_thread.h" |
#include "base/logging.h" |
+#include "base/threading/thread_local.h" |
#include "base/threading/thread_restrictions.h" |
+ |
#include "base/win/windows_version.h" |
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; |
@@ -94,6 +98,8 @@ void PlatformThread::Sleep(int duration_ms) { |
// static |
void PlatformThread::SetName(const char* name) { |
+ current_thread_name.Set(const_cast<char*>(name)); |
+ |
// The debugger needs to be around to catch the name in the exception. If |
// there isn't a debugger, we are just needlessly throwing an exception. |
if (!::IsDebuggerPresent()) |
@@ -113,6 +119,11 @@ void PlatformThread::SetName(const char* name) { |
} |
// static |
+const char* PlatformThread::GetName() { |
+ return current_thread_name.Get(); |
+} |
+ |
+// static |
bool PlatformThread::Create(size_t stack_size, Delegate* delegate, |
PlatformThreadHandle* thread_handle) { |
DCHECK(thread_handle); |