OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/android/system/base_run_loop.h" | 5 #include "mojo/android/system/base_run_loop.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/base_jni_registrar.h" | 9 #include "base/android/base_jni_registrar.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 static void Quit(JNIEnv* env, | 39 static void Quit(JNIEnv* env, |
40 const JavaParamRef<jobject>& jcaller, | 40 const JavaParamRef<jobject>& jcaller, |
41 jlong runLoopID) { | 41 jlong runLoopID) { |
42 reinterpret_cast<base::MessageLoop*>(runLoopID)->QuitWhenIdle(); | 42 reinterpret_cast<base::MessageLoop*>(runLoopID)->QuitWhenIdle(); |
43 } | 43 } |
44 | 44 |
45 static void RunJavaRunnable( | 45 static void RunJavaRunnable( |
46 const base::android::ScopedJavaGlobalRef<jobject>& runnable_ref) { | 46 const base::android::ScopedJavaGlobalRef<jobject>& runnable_ref) { |
47 Java_BaseRunLoop_runRunnable(base::android::AttachCurrentThread(), | 47 Java_BaseRunLoop_runRunnable(base::android::AttachCurrentThread(), |
48 runnable_ref.obj()); | 48 runnable_ref); |
49 } | 49 } |
50 | 50 |
51 static void PostDelayedTask(JNIEnv* env, | 51 static void PostDelayedTask(JNIEnv* env, |
52 const JavaParamRef<jobject>& jcaller, | 52 const JavaParamRef<jobject>& jcaller, |
53 jlong runLoopID, | 53 jlong runLoopID, |
54 const JavaParamRef<jobject>& runnable, | 54 const JavaParamRef<jobject>& runnable, |
55 jlong delay) { | 55 jlong delay) { |
56 base::android::ScopedJavaGlobalRef<jobject> runnable_ref; | 56 base::android::ScopedJavaGlobalRef<jobject> runnable_ref; |
57 // ScopedJavaGlobalRef do not hold onto the env reference, so it is safe to | 57 // ScopedJavaGlobalRef do not hold onto the env reference, so it is safe to |
58 // use it across threads. |RunJavaRunnable| will acquire a new JNIEnv before | 58 // use it across threads. |RunJavaRunnable| will acquire a new JNIEnv before |
(...skipping 12 matching lines...) Expand all Loading... |
71 delete message_loop; | 71 delete message_loop; |
72 } | 72 } |
73 | 73 |
74 bool RegisterBaseRunLoop(JNIEnv* env) { | 74 bool RegisterBaseRunLoop(JNIEnv* env) { |
75 return RegisterNativesImpl(env); | 75 return RegisterNativesImpl(env); |
76 } | 76 } |
77 | 77 |
78 } // namespace android | 78 } // namespace android |
79 } // namespace mojo | 79 } // namespace mojo |
80 | 80 |
OLD | NEW |