OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/debug/profiler.h" | |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
9 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
10 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
11 #include "base/tracked_objects.h" | 12 #include "base/tracked_objects.h" |
12 | 13 |
13 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 | 17 |
17 namespace { | 18 namespace { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 // thread, as it exists only in the chrome.exe image, and never spawns or runs | 127 // thread, as it exists only in the chrome.exe image, and never spawns or runs |
127 // tasks (items which could be profiled). This test avoids the notification, | 128 // tasks (items which could be profiled). This test avoids the notification, |
128 // which would also (as a side effect) initialize the profiler in this unused | 129 // which would also (as a side effect) initialize the profiler in this unused |
129 // context, including setting up thread local storage, etc. The performance | 130 // context, including setting up thread local storage, etc. The performance |
130 // impact is not terrible, but there is no reason to do initialize it. | 131 // impact is not terrible, but there is no reason to do initialize it. |
131 if (0 != strcmp(name, "BrokerEvent")) | 132 if (0 != strcmp(name, "BrokerEvent")) |
132 tracked_objects::ThreadData::InitializeThreadContext(name); | 133 tracked_objects::ThreadData::InitializeThreadContext(name); |
133 | 134 |
134 // The debugger needs to be around to catch the name in the exception. If | 135 // The debugger needs to be around to catch the name in the exception. If |
135 // there isn't a debugger, we are just needlessly throwing an exception. | 136 // there isn't a debugger, we are just needlessly throwing an exception. |
136 if (!::IsDebuggerPresent()) | 137 // If this image file is instrumented, we raise the exception anyway |
138 // to provide the profiler with human-readable thread names. | |
139 if (!::IsDebuggerPresent() && !base::debug::IsBinaryInstrumented()) | |
jar (doing other things)
2012/05/30 19:41:23
FWIW: In the about:profiler world, we depend on a
Sigurður Ásgeirsson
2012/05/30 20:52:12
Yups, as per my previous message, this is more use
| |
137 return; | 140 return; |
138 | 141 |
139 SetNameInternal(CurrentId(), name); | 142 SetNameInternal(CurrentId(), name); |
140 } | 143 } |
141 | 144 |
142 // static | 145 // static |
143 const char* PlatformThread::GetName() { | 146 const char* PlatformThread::GetName() { |
144 return current_thread_name.Get(); | 147 return current_thread_name.Get(); |
145 } | 148 } |
146 | 149 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 case kThreadPriority_Normal: | 203 case kThreadPriority_Normal: |
201 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL); | 204 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL); |
202 break; | 205 break; |
203 case kThreadPriority_RealtimeAudio: | 206 case kThreadPriority_RealtimeAudio: |
204 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); | 207 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); |
205 break; | 208 break; |
206 } | 209 } |
207 } | 210 } |
208 | 211 |
209 } // namespace base | 212 } // namespace base |
OLD | NEW |