Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: base/threading/platform_thread_win.cc

Issue 11438022: Add ability to retrieve a thread_name given a thread_id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move the set to PlatformThread::SetName so we catch any name changes. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/debug/profiler.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/thread_id_name_manager.h"
10 #include "base/threading/thread_local.h" 11 #include "base/threading/thread_local.h"
11 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
12 #include "base/tracked_objects.h" 13 #include "base/tracked_objects.h"
13 14
14 #include "base/win/windows_version.h" 15 #include "base/win/windows_version.h"
15 16
16 namespace base { 17 namespace base {
17 18
18 namespace { 19 namespace {
19 20
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 112
112 // static 113 // static
113 void PlatformThread::Sleep(TimeDelta duration) { 114 void PlatformThread::Sleep(TimeDelta duration) {
114 ::Sleep(duration.InMillisecondsRoundedUp()); 115 ::Sleep(duration.InMillisecondsRoundedUp());
115 } 116 }
116 117
117 // static 118 // static
118 void PlatformThread::SetName(const char* name) { 119 void PlatformThread::SetName(const char* name) {
119 current_thread_name.Set(const_cast<char*>(name)); 120 current_thread_name.Set(const_cast<char*>(name));
120 121
122 ThreadIdNameManager::GetInstance()->SetNameForId(CurrentId(), name);
123
121 // On Windows only, we don't need to tell the profiler about the "BrokerEvent" 124 // On Windows only, we don't need to tell the profiler about the "BrokerEvent"
122 // thread, as it exists only in the chrome.exe image, and never spawns or runs 125 // thread, as it exists only in the chrome.exe image, and never spawns or runs
123 // tasks (items which could be profiled). This test avoids the notification, 126 // tasks (items which could be profiled). This test avoids the notification,
124 // which would also (as a side effect) initialize the profiler in this unused 127 // which would also (as a side effect) initialize the profiler in this unused
125 // context, including setting up thread local storage, etc. The performance 128 // context, including setting up thread local storage, etc. The performance
126 // impact is not terrible, but there is no reason to do initialize it. 129 // impact is not terrible, but there is no reason to do initialize it.
127 if (0 != strcmp(name, "BrokerEvent")) 130 if (0 != strcmp(name, "BrokerEvent"))
128 tracked_objects::ThreadData::InitializeThreadContext(name); 131 tracked_objects::ThreadData::InitializeThreadContext(name);
129 132
130 // The debugger needs to be around to catch the name in the exception. If 133 // The debugger needs to be around to catch the name in the exception. If
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 case kThreadPriority_Normal: 201 case kThreadPriority_Normal:
199 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL); 202 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL);
200 break; 203 break;
201 case kThreadPriority_RealtimeAudio: 204 case kThreadPriority_RealtimeAudio:
202 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); 205 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
203 break; 206 break;
204 } 207 }
205 } 208 }
206 209
207 } // namespace base 210 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698