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

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: (rebase for review) Created 5 years, 6 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
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..56611703736c2a1ef6d931bde248aa8cd8bff869 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -56,8 +56,7 @@ DWORD __stdcall ThreadFunc(void* params) {
base::ThreadRestrictions::SetSingletonAllowed(false);
if (thread_params->priority != ThreadPriority::NORMAL) {
- PlatformThread::SetThreadPriority(
- PlatformThread::CurrentHandle(), thread_params->priority);
+ PlatformThread::SetCurrentThreadPriority(thread_params->priority);
}
gab 2015/06/26 15:57:13 nit: can remove {}
Takashi Toyoshima 2015/06/29 05:48:51 Done.
// Retrieve a copy of the thread handle to use as the key in the
@@ -238,8 +237,7 @@ void PlatformThread::Join(PlatformThreadHandle thread_handle) {
}
// static
-void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
- ThreadPriority priority) {
+void PlatformThread::SetCurrentThreadPriority(ThreadPriority priority) {
DCHECK(!handle.is_null());
int desired_priority = THREAD_PRIORITY_ERROR_RETURN;
@@ -265,16 +263,18 @@ 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) {
+ThreadPriority PlatformThread::GetCurrentThreadPriority() {
DCHECK(!handle.is_null());
- int priority = ::GetThreadPriority(handle.platform_handle());
+ int priority =
+ ::GetThreadPriority(PlatformThread::CurrentHandle().platform_handle());
switch (priority) {
case THREAD_PRIORITY_LOWEST:
return ThreadPriority::BACKGROUND;

Powered by Google App Engine
This is Rietveld 408576698