OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/android/java_handler_thread.h" | 5 #include "base/android/java_handler_thread.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
14 #include "jni/JavaHandlerThread_jni.h" | 14 #include "jni/JavaHandlerThread_jni.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 namespace android { | 18 namespace android { |
19 | 19 |
20 JavaHandlerThread::JavaHandlerThread(const char* name) { | 20 JavaHandlerThread::JavaHandlerThread(const char* name) { |
21 JNIEnv* env = base::android::AttachCurrentThread(); | 21 JNIEnv* env = base::android::AttachCurrentThread(); |
22 | 22 |
23 java_thread_.Reset(Java_JavaHandlerThread_create( | 23 java_thread_.Reset(Java_JavaHandlerThread_create( |
24 env, ConvertUTF8ToJavaString(env, name).Release())); | 24 env, ConvertUTF8ToJavaString(env, name).obj())); |
25 } | 25 } |
26 | 26 |
27 JavaHandlerThread::~JavaHandlerThread() { | 27 JavaHandlerThread::~JavaHandlerThread() { |
28 } | 28 } |
29 | 29 |
30 void JavaHandlerThread::Start() { | 30 void JavaHandlerThread::Start() { |
31 // Check the thread has not already been started. | 31 // Check the thread has not already been started. |
32 DCHECK(!message_loop_); | 32 DCHECK(!message_loop_); |
33 | 33 |
34 JNIEnv* env = base::android::AttachCurrentThread(); | 34 JNIEnv* env = base::android::AttachCurrentThread(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 reinterpret_cast<base::WaitableEvent*>(event)->Signal(); | 68 reinterpret_cast<base::WaitableEvent*>(event)->Signal(); |
69 } | 69 } |
70 | 70 |
71 // static | 71 // static |
72 bool JavaHandlerThread::RegisterBindings(JNIEnv* env) { | 72 bool JavaHandlerThread::RegisterBindings(JNIEnv* env) { |
73 return RegisterNativesImpl(env); | 73 return RegisterNativesImpl(env); |
74 } | 74 } |
75 | 75 |
76 } // namespace android | 76 } // namespace android |
77 } // namespace base | 77 } // namespace base |
OLD | NEW |