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

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

Issue 1123833003: Revert of Revert some other possible suspects of a 0.43% size increase of setup.exe: https://build.chromium.o… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « base/threading/platform_thread_mac.mm ('k') | base/threading/simple_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_id_name_manager.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // static 147 // static
148 void PlatformThread::Sleep(TimeDelta duration) { 148 void PlatformThread::Sleep(TimeDelta duration) {
149 // When measured with a high resolution clock, Sleep() sometimes returns much 149 // When measured with a high resolution clock, Sleep() sometimes returns much
150 // too early. We may need to call it repeatedly to get the desired duration. 150 // too early. We may need to call it repeatedly to get the desired duration.
151 TimeTicks end = TimeTicks::Now() + duration; 151 TimeTicks end = TimeTicks::Now() + duration;
152 for (TimeTicks now = TimeTicks::Now(); now < end; now = TimeTicks::Now()) 152 for (TimeTicks now = TimeTicks::Now(); now < end; now = TimeTicks::Now())
153 ::Sleep(static_cast<DWORD>((end - now).InMillisecondsRoundedUp())); 153 ::Sleep(static_cast<DWORD>((end - now).InMillisecondsRoundedUp()));
154 } 154 }
155 155
156 // static 156 // static
157 void PlatformThread::SetName(const char* name) { 157 void PlatformThread::SetName(const std::string& name) {
158 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name); 158 ThreadIdNameManager::GetInstance()->SetName(CurrentId(), name);
159 159
160 // On Windows only, we don't need to tell the profiler about the "BrokerEvent" 160 // On Windows only, we don't need to tell the profiler about the "BrokerEvent"
161 // thread, as it exists only in the chrome.exe image, and never spawns or runs 161 // thread, as it exists only in the chrome.exe image, and never spawns or runs
162 // tasks (items which could be profiled). This test avoids the notification, 162 // tasks (items which could be profiled). This test avoids the notification,
163 // which would also (as a side effect) initialize the profiler in this unused 163 // which would also (as a side effect) initialize the profiler in this unused
164 // context, including setting up thread local storage, etc. The performance 164 // context, including setting up thread local storage, etc. The performance
165 // impact is not terrible, but there is no reason to do initialize it. 165 // impact is not terrible, but there is no reason to do initialize it.
166 if (0 != strcmp(name, "BrokerEvent")) 166 if (name != "BrokerEvent")
167 tracked_objects::ThreadData::InitializeThreadContext(name); 167 tracked_objects::ThreadData::InitializeThreadContext(name);
168 168
169 // The debugger needs to be around to catch the name in the exception. If 169 // The debugger needs to be around to catch the name in the exception. If
170 // there isn't a debugger, we are just needlessly throwing an exception. 170 // there isn't a debugger, we are just needlessly throwing an exception.
171 // If this image file is instrumented, we raise the exception anyway 171 // If this image file is instrumented, we raise the exception anyway
172 // to provide the profiler with human-readable thread names. 172 // to provide the profiler with human-readable thread names.
173 if (!::IsDebuggerPresent() && !base::debug::IsBinaryInstrumented()) 173 if (!::IsDebuggerPresent() && !base::debug::IsBinaryInstrumented())
174 return; 174 return;
175 175
176 SetNameInternal(CurrentId(), name); 176 SetNameInternal(CurrentId(), name.c_str());
177 } 177 }
178 178
179 // static 179 // static
180 const char* PlatformThread::GetName() { 180 const char* PlatformThread::GetName() {
181 return ThreadIdNameManager::GetInstance()->GetName(CurrentId()); 181 return ThreadIdNameManager::GetInstance()->GetName(CurrentId());
182 } 182 }
183 183
184 // static 184 // static
185 bool PlatformThread::Create(size_t stack_size, Delegate* delegate, 185 bool PlatformThread::Create(size_t stack_size, Delegate* delegate,
186 PlatformThreadHandle* thread_handle) { 186 PlatformThreadHandle* thread_handle) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 return ThreadPriority::REALTIME_AUDIO; 279 return ThreadPriority::REALTIME_AUDIO;
280 case THREAD_PRIORITY_ERROR_RETURN: 280 case THREAD_PRIORITY_ERROR_RETURN:
281 DPCHECK(false) << "GetThreadPriority error"; // Falls through. 281 DPCHECK(false) << "GetThreadPriority error"; // Falls through.
282 default: 282 default:
283 NOTREACHED() << "Unexpected priority: " << priority; 283 NOTREACHED() << "Unexpected priority: " << priority;
284 return ThreadPriority::NORMAL; 284 return ThreadPriority::NORMAL;
285 } 285 }
286 } 286 }
287 287
288 } // namespace base 288 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/platform_thread_mac.mm ('k') | base/threading/simple_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698