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

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

Issue 1051863003: Turn ThreadPriority enum into an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@setthreadpri
Patch Set: nits Created 5 years, 8 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_unittest.cc ('k') | content/browser/browser_main_loop.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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 CloseHandle(thread_handle.handle_); 230 CloseHandle(thread_handle.handle_);
231 } 231 }
232 232
233 // static 233 // static
234 void PlatformThread::SetThreadPriority(PlatformThreadHandle handle, 234 void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
235 ThreadPriority priority) { 235 ThreadPriority priority) {
236 DCHECK(!handle.is_null()); 236 DCHECK(!handle.is_null());
237 237
238 int desired_priority = THREAD_PRIORITY_ERROR_RETURN; 238 int desired_priority = THREAD_PRIORITY_ERROR_RETURN;
239 switch (priority) { 239 switch (priority) {
240 case kThreadPriority_Normal: 240 case ThreadPriority::BACKGROUND:
241 desired_priority = THREAD_PRIORITY_LOWEST;
242 break;
243 case ThreadPriority::NORMAL:
241 desired_priority = THREAD_PRIORITY_NORMAL; 244 desired_priority = THREAD_PRIORITY_NORMAL;
242 break; 245 break;
243 case kThreadPriority_RealtimeAudio: 246 case ThreadPriority::DISPLAY:
244 desired_priority = THREAD_PRIORITY_TIME_CRITICAL;
245 break;
246 case kThreadPriority_Display:
247 desired_priority = THREAD_PRIORITY_ABOVE_NORMAL; 247 desired_priority = THREAD_PRIORITY_ABOVE_NORMAL;
248 break; 248 break;
249 case kThreadPriority_Background: 249 case ThreadPriority::REALTIME_AUDIO:
250 desired_priority = THREAD_PRIORITY_LOWEST; 250 desired_priority = THREAD_PRIORITY_TIME_CRITICAL;
251 break; 251 break;
252 default: 252 default:
253 NOTREACHED() << "Unknown priority."; 253 NOTREACHED() << "Unknown priority.";
254 break; 254 break;
255 } 255 }
256 DCHECK_NE(desired_priority, THREAD_PRIORITY_ERROR_RETURN); 256 DCHECK_NE(desired_priority, THREAD_PRIORITY_ERROR_RETURN);
257 257
258 #ifndef NDEBUG 258 #ifndef NDEBUG
259 const BOOL success = 259 const BOOL success =
260 #endif 260 #endif
261 ::SetThreadPriority(handle.handle_, desired_priority); 261 ::SetThreadPriority(handle.handle_, desired_priority);
262 DPLOG_IF(ERROR, !success) << "Failed to set thread priority to " 262 DPLOG_IF(ERROR, !success) << "Failed to set thread priority to "
263 << desired_priority; 263 << desired_priority;
264 } 264 }
265 265
266 // static 266 // static
267 ThreadPriority PlatformThread::GetThreadPriority(PlatformThreadHandle handle) { 267 ThreadPriority PlatformThread::GetThreadPriority(PlatformThreadHandle handle) {
268 DCHECK(!handle.is_null()); 268 DCHECK(!handle.is_null());
269 269
270 int priority = ::GetThreadPriority(handle.handle_); 270 int priority = ::GetThreadPriority(handle.handle_);
271 switch (priority) { 271 switch (priority) {
272 case THREAD_PRIORITY_LOWEST:
273 return ThreadPriority::BACKGROUND;
272 case THREAD_PRIORITY_NORMAL: 274 case THREAD_PRIORITY_NORMAL:
273 return kThreadPriority_Normal; 275 return ThreadPriority::NORMAL;
276 case THREAD_PRIORITY_ABOVE_NORMAL:
277 return ThreadPriority::DISPLAY;
274 case THREAD_PRIORITY_TIME_CRITICAL: 278 case THREAD_PRIORITY_TIME_CRITICAL:
275 return kThreadPriority_RealtimeAudio; 279 return ThreadPriority::REALTIME_AUDIO;
276 case THREAD_PRIORITY_ABOVE_NORMAL:
277 return kThreadPriority_Display;
278 case THREAD_PRIORITY_LOWEST:
279 return kThreadPriority_Background;
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 kThreadPriority_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_unittest.cc ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698