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

Unified Diff: base/threading/platform_thread_linux.cc

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest 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 side-by-side diff with in-line comments
Download patch
Index: base/threading/platform_thread_linux.cc
diff --git a/base/threading/platform_thread_linux.cc b/base/threading/platform_thread_linux.cc
index 623a3dee678352aaf8a61b402c431a1727aa2fd9..b72fb5bb24b499bc1cac4faf72ac99b7b8be5c28 100644
--- a/base/threading/platform_thread_linux.cc
+++ b/base/threading/platform_thread_linux.cc
@@ -31,22 +31,42 @@ const struct sched_param kRealTimePrio = {8};
} // namespace
const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = {
- {kThreadPriority_RealtimeAudio, -10},
- {kThreadPriority_Background, 10},
- {kThreadPriority_Normal, 0},
- {kThreadPriority_Display, -6},
+ {ThreadPriority::BACKGROUND, 10},
+ {ThreadPriority::NORMAL, 0},
+ {ThreadPriority::DISPLAY, -6},
+ {ThreadPriority::REALTIME_AUDIO, -10},
};
-bool HandleSetThreadPriorityForPlatform(PlatformThreadHandle handle,
- ThreadPriority priority) {
+bool SetThreadPriorityForPlatform(PlatformThreadHandle handle,
+ ThreadPriority priority) {
#if !defined(OS_NACL)
- return priority == kThreadPriority_RealtimeAudio &&
+ // TODO(gab): Assess the correctness of using |pthread_self()| below instead
+ // of |handle|. http://crbug.com/468793.
+ return priority == ThreadPriority::REALTIME_AUDIO &&
pthread_setschedparam(pthread_self(), SCHED_RR, &kRealTimePrio) == 0;
#else
return false;
#endif
}
+bool GetThreadPriorityForPlatform(PlatformThreadHandle handle,
+ ThreadPriority* priority) {
+#if !defined(OS_NACL)
+ int maybe_sched_rr = 0;
+ struct sched_param maybe_realtime_prio = {0};
+ // TODO(gab): Assess the correctness of using |pthread_self()| below instead
+ // of |handle|. http://crbug.com/468793.
+ if (pthread_getschedparam(pthread_self(), &maybe_sched_rr,
+ &maybe_realtime_prio) == 0 &&
+ maybe_sched_rr == SCHED_RR &&
+ maybe_realtime_prio.sched_priority == kRealTimePrio.sched_priority) {
+ *priority = ThreadPriority::REALTIME_AUDIO;
+ return true;
+ }
+#endif
+ return false;
+}
+
} // namespace internal
// static

Powered by Google App Engine
This is Rietveld 408576698