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

Unified Diff: base/threading/platform_thread_win.cc

Issue 1193303002: base/threading: restrict to set only current thread priority (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review #48 Created 5 years, 5 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_win.cc
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index c2eab6ccfd3e7462ec9816dee32ef54204c0f3f7..059547b10ed2728d7d80580adf23d31374e11b0d 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -55,10 +55,8 @@ DWORD __stdcall ThreadFunc(void* params) {
if (!thread_params->joinable)
base::ThreadRestrictions::SetSingletonAllowed(false);
- if (thread_params->priority != ThreadPriority::NORMAL) {
- PlatformThread::SetThreadPriority(
- PlatformThread::CurrentHandle(), thread_params->priority);
- }
+ if (thread_params->priority != ThreadPriority::NORMAL)
+ PlatformThread::SetCurrentThreadPriority(thread_params->priority);
// Retrieve a copy of the thread handle to use as the key in the
// thread name mapping.
@@ -238,10 +236,7 @@ void PlatformThread::Join(PlatformThreadHandle thread_handle) {
}
// static
-void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
- ThreadPriority priority) {
- DCHECK(!handle.is_null());
-
+void PlatformThread::SetCurrentThreadPriority(ThreadPriority priority) {
int desired_priority = THREAD_PRIORITY_ERROR_RETURN;
switch (priority) {
case ThreadPriority::BACKGROUND:
@@ -265,16 +260,16 @@ void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
#ifndef NDEBUG
const BOOL success =
#endif
- ::SetThreadPriority(handle.platform_handle(), desired_priority);
+ ::SetThreadPriority(PlatformThread::CurrentHandle().platform_handle(),
+ desired_priority);
DPLOG_IF(ERROR, !success) << "Failed to set thread priority to "
<< desired_priority;
}
// static
-ThreadPriority PlatformThread::GetThreadPriority(PlatformThreadHandle handle) {
- DCHECK(!handle.is_null());
-
- int priority = ::GetThreadPriority(handle.platform_handle());
+ThreadPriority PlatformThread::GetCurrentThreadPriority() {
+ int priority =
+ ::GetThreadPriority(PlatformThread::CurrentHandle().platform_handle());
switch (priority) {
case THREAD_PRIORITY_LOWEST:
return ThreadPriority::BACKGROUND;
« 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