Index: base/threading/platform_thread_win.cc |
=================================================================== |
--- base/threading/platform_thread_win.cc (revision 110002) |
+++ base/threading/platform_thread_win.cc (working copy) |
@@ -8,6 +8,7 @@ |
#include "base/logging.h" |
#include "base/threading/thread_local.h" |
#include "base/threading/thread_restrictions.h" |
+#include "base/tracked_objects.h" |
#include "base/win/windows_version.h" |
@@ -28,6 +29,21 @@ |
DWORD dwFlags; // Reserved for future use, must be zero. |
} THREADNAME_INFO; |
+// This function has try handling, so it is separated out of its caller. |
+void SetNameInternal(PlatformThreadId thread_id, const char* name) { |
+ THREADNAME_INFO info; |
+ info.dwType = 0x1000; |
+ info.szName = name; |
+ info.dwThreadID = thread_id; |
+ info.dwFlags = 0; |
+ |
+ __try { |
+ RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD), |
+ reinterpret_cast<DWORD_PTR*>(&info)); |
+ } __except(EXCEPTION_CONTINUE_EXECUTION) { |
+ } |
+} |
+ |
struct ThreadParams { |
PlatformThread::Delegate* delegate; |
bool joinable; |
@@ -100,23 +116,14 @@ |
// static |
void PlatformThread::SetName(const char* name) { |
current_thread_name.Set(const_cast<char*>(name)); |
+ tracked_objects::ThreadData::InitializeThreadContext(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()) |
return; |
- THREADNAME_INFO info; |
- info.dwType = 0x1000; |
- info.szName = name; |
- info.dwThreadID = CurrentId(); |
- info.dwFlags = 0; |
- |
- __try { |
- RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD), |
- reinterpret_cast<DWORD_PTR*>(&info)); |
- } __except(EXCEPTION_CONTINUE_EXECUTION) { |
- } |
+ SetNameInternal(CurrentId(), name); |
} |
// static |