Chromium Code Reviews| Index: base/threading/platform_thread_posix.cc |
| diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc |
| index 444edc58a6268649115f2f1583bc7b56374d961d..438002b034c2edcd1d48b9247919b01d0399cc25 100644 |
| --- a/base/threading/platform_thread_posix.cc |
| +++ b/base/threading/platform_thread_posix.cc |
| @@ -30,6 +30,7 @@ |
| #if defined(OS_ANDROID) |
| #include "base/android/jni_android.h" |
| +#include "jni/ThreadUtils_jni.h" |
| #endif |
| // TODO(bbudge) Use time.h when NaCl toolchain supports _POSIX_TIMERS |
| @@ -274,13 +275,30 @@ void PlatformThread::Join(PlatformThreadHandle thread_handle) { |
| pthread_join(thread_handle, NULL); |
| } |
| -#if !defined(OS_MACOSX) |
| -// Mac OS X uses lower-level mach APIs. |
| - |
| +#if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| +// Mac OS X uses lower-level mach APIs and Android uses Java APIs. |
| // static |
| void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
| // TODO(crogers): Implement, see http://crbug.com/116172 |
| } |
| #endif |
| +#if defined(OS_ANDROID) |
| +bool RegisterThreadUtils(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
|
bulach
2013/01/09 12:57:58
nit: unindent -2
Wei James(wistoch)
2013/01/10 08:30:05
fixed. thanks
|
| +} |
| + |
| +void PlatformThread::SetThreadPriority(PlatformThreadHandle, |
| + ThreadPriority priority) { |
| + // Use Android SDK API to set priority for real time audio thread and it will |
| + // set the thread to corresponding cgroups. |
|
bulach
2013/01/09 12:57:58
this comment is a bit spurious, since it's just ma
Wei James(wistoch)
2013/01/10 08:30:05
removed, thanks
|
| + if (priority == kThreadPriority_RealtimeAudio) { |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + Java_ThreadUtils_setAudioThreadPriority(env, PlatformThread::CurrentId()); |
|
bulach
2013/01/09 12:57:58
nit: as above, maybe rename to ..._setThreadPriori
Wei James(wistoch)
2013/01/10 08:30:05
fixed. thanks
|
| + } else { |
| + NOTREACHED() << "Unknown thread priority."; |
| + } |
| +} |
| +#endif |
|
bulach
2013/01/09 12:57:58
nit: // defined(OS_ANDROID)
Wei James(wistoch)
2013/01/10 08:30:05
fixed. thanks
|
| + |
| } // namespace base |