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

Unified Diff: base/threading/platform_thread_android.cc

Issue 1784623005: Test dynamic priorities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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.h ('k') | base/threading/platform_thread_internal_posix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_android.cc
diff --git a/base/threading/platform_thread_android.cc b/base/threading/platform_thread_android.cc
index fd5e54d8af961fe03c90d3bd6c7b61b111aa6f13..d2648d0eeeeb364d1e0ff204c509217809e8e2da 100644
--- a/base/threading/platform_thread_android.cc
+++ b/base/threading/platform_thread_android.cc
@@ -47,6 +47,19 @@ bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) {
return false;
}
+bool SetThreadPriority(PlatformThreadId tid, ThreadPriority priority) {
+ if (priority == ThreadPriority::BACKGROUND) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_ThreadUtils_setThreadPriorityBackground(env, tid);
+ return true;
+ } else if (priority == ThreadPriority::NORMAL) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_ThreadUtils_setThreadPriorityNormal(env, tid);
+ return true;
+ }
+ return false;
+}
+
bool GetCurrentThreadPriorityForPlatform(ThreadPriority* priority) {
DCHECK(priority);
*priority = ThreadPriority::NORMAL;
@@ -55,6 +68,14 @@ bool GetCurrentThreadPriorityForPlatform(ThreadPriority* priority) {
env, PlatformThread::CurrentId())) {
*priority = ThreadPriority::REALTIME_AUDIO;
return true;
+ } else if (Java_ThreadUtils_isThreadPriorityNormal(
+ env, PlatformThread::CurrentId())) {
+ *priority = ThreadPriority::NORMAL;
+ return true;
+ } else if (Java_ThreadUtils_isThreadPriorityBackground(
+ env, PlatformThread::CurrentId())) {
+ *priority = ThreadPriority::BACKGROUND;
+ return true;
}
return false;
}
« no previous file with comments | « base/threading/platform_thread.h ('k') | base/threading/platform_thread_internal_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698