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

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: two more android fix and review #2 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 395fc9e20173ad00797c85248584a9d7d1826d7d..520fcd353b2cb1d12e6734ad49635936248b69b3 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -195,7 +195,7 @@ bool PlatformThread::CreateWithPriority(size_t stack_size, Delegate* delegate,
ThreadPriority priority) {
bool result = Create(stack_size, delegate, thread_handle);
if (result)
- SetThreadPriority(*thread_handle, priority);
+ SetCurrentThreadPriority(priority);
gab 2015/06/23 17:01:32 Hmm, this is incorrect no? This code runs on the t
Takashi Toyoshima 2015/06/24 04:15:39 Oops, thank you for catching this. Yes, definitely
return result;
}
@@ -231,10 +231,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:
@@ -258,16 +255,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;

Powered by Google App Engine
This is Rietveld 408576698