Skip to content

Commit

Permalink
Adding GetCurrentThreadPriority API in Android platform.
Browse files Browse the repository at this point in the history
This change takes care of implementing GetCurrentThreadPriory in
Android platform. Currently it is left NOTIMPLEMENTED(), due to
which some unit test cases has to mark not to execute on Android.

BUG=505474

Review URL: https://codereview.chromium.org/1216933009

Cr-Commit-Position: refs/heads/master@{#351563}
  • Loading branch information
ajith.v authored and Commit bot committed Sep 30, 2015
1 parent f72d28c commit 942dd0e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions base/android/java/src/org/chromium/base/ThreadUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,14 @@ public static Looper getUiThreadLooper() {
public static void setThreadPriorityAudio(int tid) {
Process.setThreadPriority(tid, Process.THREAD_PRIORITY_AUDIO);
}

/**
* Checks whether Thread priority is THREAD_PRIORITY_AUDIO or not.
* @param tid Thread id.
* @return true for THREAD_PRIORITY_AUDIO and false otherwise.
*/
@CalledByNative
private static boolean isThreadPriorityAudio(int tid) {
return Process.getThreadPriority(tid) == Process.THREAD_PRIORITY_AUDIO;
}
}
10 changes: 8 additions & 2 deletions base/threading/platform_thread_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) {
}

bool GetCurrentThreadPriorityForPlatform(ThreadPriority* priority) {
// See http://crbug.com/505474.
NOTIMPLEMENTED();
DCHECK(priority);
*priority = ThreadPriority::NORMAL;
JNIEnv* env = base::android::AttachCurrentThread();
if (Java_ThreadUtils_isThreadPriorityAudio(
env, PlatformThread::CurrentId())) {
*priority = ThreadPriority::REALTIME_AUDIO;
return true;
}
return false;
}

Expand Down

0 comments on commit 942dd0e

Please sign in to comment.