Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/threading/platform_thread.h" | 5 #include "base/threading/platform_thread.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sched.h> | 8 #include <sched.h> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #if defined(OS_LINUX) | 23 #if defined(OS_LINUX) |
| 24 #include <sys/prctl.h> | 24 #include <sys/prctl.h> |
| 25 #include <sys/resource.h> | 25 #include <sys/resource.h> |
| 26 #include <sys/syscall.h> | 26 #include <sys/syscall.h> |
| 27 #include <sys/time.h> | 27 #include <sys/time.h> |
| 28 #include <unistd.h> | 28 #include <unistd.h> |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 #if defined(OS_ANDROID) | 31 #if defined(OS_ANDROID) |
| 32 #include "base/android/jni_android.h" | 32 #include "base/android/jni_android.h" |
| 33 #include "jni/ThreadUtils_jni.h" | |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 // TODO(bbudge) Use time.h when NaCl toolchain supports _POSIX_TIMERS | 36 // TODO(bbudge) Use time.h when NaCl toolchain supports _POSIX_TIMERS |
| 36 #if defined(OS_NACL) | 37 #if defined(OS_NACL) |
| 37 #include <sys/nacl_syscalls.h> | 38 #include <sys/nacl_syscalls.h> |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 namespace base { | 41 namespace base { |
| 41 | 42 |
| 42 #if defined(OS_MACOSX) | 43 #if defined(OS_MACOSX) |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 | 268 |
| 268 // static | 269 // static |
| 269 void PlatformThread::Join(PlatformThreadHandle thread_handle) { | 270 void PlatformThread::Join(PlatformThreadHandle thread_handle) { |
| 270 // Joining another thread may block the current thread for a long time, since | 271 // Joining another thread may block the current thread for a long time, since |
| 271 // the thread referred to by |thread_handle| may still be running long-lived / | 272 // the thread referred to by |thread_handle| may still be running long-lived / |
| 272 // blocking tasks. | 273 // blocking tasks. |
| 273 base::ThreadRestrictions::AssertIOAllowed(); | 274 base::ThreadRestrictions::AssertIOAllowed(); |
| 274 pthread_join(thread_handle, NULL); | 275 pthread_join(thread_handle, NULL); |
| 275 } | 276 } |
| 276 | 277 |
| 277 #if !defined(OS_MACOSX) | 278 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 278 // Mac OS X uses lower-level mach APIs. | 279 // Mac OS X uses lower-level mach APIs and Android uses Java APIs. |
| 279 | |
| 280 // static | 280 // static |
| 281 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 281 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
| 282 // TODO(crogers): Implement, see http://crbug.com/116172 | 282 // TODO(crogers): Implement, see http://crbug.com/116172 |
| 283 } | 283 } |
| 284 #endif | 284 #endif |
| 285 | 285 |
| 286 #if defined(OS_ANDROID) | |
| 287 bool RegisterThreadUtils(JNIEnv* env) { | |
| 288 return RegisterNativesImpl(env); | |
| 289 } | |
| 290 | |
| 291 void PlatformThread::SetThreadPriority(PlatformThreadHandle, | |
| 292 ThreadPriority priority) { | |
| 293 if (priority == kThreadPriority_RealtimeAudio) { | |
| 294 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 295 Java_ThreadUtils_setThreadPriorityAudio(env, PlatformThread::CurrentId()); | |
| 296 } else { | |
| 297 NOTREACHED() << "Unknown thread priority."; | |
| 298 } | |
| 299 } | |
| 300 #endif // defined(OS_ANDROID) | |
|
Mark Mentovai
2013/01/23 13:59:19
Nit: this needs another space between #endif and /
Wei James(wistoch)
2013/01/24 00:41:59
fixed. thanks
| |
| 301 | |
| 286 } // namespace base | 302 } // namespace base |
| OLD | NEW |