| Index: base/threading/platform_thread_win.cc
|
| diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
|
| index e9752ba21394c671d1d84214e4cd65078bd940f3..a3984d62b5712d644d1277b2ff023494c4778626 100644
|
| --- a/base/threading/platform_thread_win.cc
|
| +++ b/base/threading/platform_thread_win.cc
|
| @@ -10,7 +10,7 @@
|
| #include "base/threading/thread_id_name_manager.h"
|
| #include "base/threading/thread_restrictions.h"
|
| #include "base/tracked_objects.h"
|
| -
|
| +#include "base/win/scoped_handle.h"
|
| #include "base/win/windows_version.h"
|
|
|
| namespace base {
|
| @@ -54,28 +54,35 @@ DWORD __stdcall ThreadFunc(void* params) {
|
| if (!thread_params->joinable)
|
| base::ThreadRestrictions::SetSingletonAllowed(false);
|
|
|
| - /* Retrieve a copy of the thread handle to use as the key in the
|
| - * thread name mapping. */
|
| + // Retrieve a copy of the thread handle to use as the key in the
|
| + // thread name mapping.
|
| PlatformThreadHandle::Handle platform_handle;
|
| - DuplicateHandle(
|
| - GetCurrentProcess(),
|
| - GetCurrentThread(),
|
| - GetCurrentProcess(),
|
| - &platform_handle,
|
| - 0,
|
| - FALSE,
|
| - DUPLICATE_SAME_ACCESS);
|
| -
|
| - ThreadIdNameManager::GetInstance()->RegisterThread(
|
| - platform_handle,
|
| - PlatformThread::CurrentId());
|
| + BOOL did_dup = DuplicateHandle(GetCurrentProcess(),
|
| + GetCurrentThread(),
|
| + GetCurrentProcess(),
|
| + &platform_handle,
|
| + 0,
|
| + FALSE,
|
| + DUPLICATE_SAME_ACCESS);
|
| +
|
| + win::ScopedHandle scoped_platform_handle;
|
| +
|
| + if (did_dup) {
|
| + scoped_platform_handle.Set(platform_handle);
|
| + ThreadIdNameManager::GetInstance()->RegisterThread(
|
| + scoped_platform_handle.Get(),
|
| + PlatformThread::CurrentId());
|
| + }
|
|
|
| delete thread_params;
|
| delegate->ThreadMain();
|
|
|
| - ThreadIdNameManager::GetInstance()->RemoveName(
|
| - platform_handle,
|
| - PlatformThread::CurrentId());
|
| + if (did_dup) {
|
| + ThreadIdNameManager::GetInstance()->RemoveName(
|
| + scoped_platform_handle.Get(),
|
| + PlatformThread::CurrentId());
|
| + }
|
| +
|
| return NULL;
|
| }
|
|
|
|
|