| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/threading/platform_thread.h" | 5 #include "base/threading/platform_thread.h" |
| 6 | 6 |
| 7 #include "base/debug/alias.h" | 7 #include "base/debug/alias.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/threading/thread_local.h" | 9 #include "base/threading/thread_local.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 11 #include "base/tracked_objects.h" |
| 11 | 12 |
| 12 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 static ThreadLocalPointer<char> current_thread_name; | 19 static ThreadLocalPointer<char> current_thread_name; |
| 19 | 20 |
| 20 // The information on how to set the thread name comes from | 21 // The information on how to set the thread name comes from |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 94 } |
| 94 | 95 |
| 95 // static | 96 // static |
| 96 void PlatformThread::Sleep(int duration_ms) { | 97 void PlatformThread::Sleep(int duration_ms) { |
| 97 ::Sleep(duration_ms); | 98 ::Sleep(duration_ms); |
| 98 } | 99 } |
| 99 | 100 |
| 100 // static | 101 // static |
| 101 void PlatformThread::SetName(const char* name) { | 102 void PlatformThread::SetName(const char* name) { |
| 102 current_thread_name.Set(const_cast<char*>(name)); | 103 current_thread_name.Set(const_cast<char*>(name)); |
| 104 tracked_objects::ThreadData::InitializeThreadContext(name); |
| 103 | 105 |
| 104 // The debugger needs to be around to catch the name in the exception. If | 106 // The debugger needs to be around to catch the name in the exception. If |
| 105 // there isn't a debugger, we are just needlessly throwing an exception. | 107 // there isn't a debugger, we are just needlessly throwing an exception. |
| 106 if (!::IsDebuggerPresent()) | 108 if (!::IsDebuggerPresent()) |
| 107 return; | 109 return; |
| 108 | 110 |
| 109 THREADNAME_INFO info; | 111 THREADNAME_INFO info; |
| 110 info.dwType = 0x1000; | 112 info.dwType = 0x1000; |
| 111 info.szName = name; | 113 info.szName = name; |
| 112 info.dwThreadID = CurrentId(); | 114 info.dwThreadID = CurrentId(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 case kThreadPriority_RealtimeAudio: | 168 case kThreadPriority_RealtimeAudio: |
| 167 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); | 169 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); |
| 168 break; | 170 break; |
| 169 default: | 171 default: |
| 170 NOTIMPLEMENTED(); | 172 NOTIMPLEMENTED(); |
| 171 break; | 173 break; |
| 172 } | 174 } |
| 173 } | 175 } |
| 174 | 176 |
| 175 } // namespace base | 177 } // namespace base |
| OLD | NEW |