Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/android/system/base_run_loop.h" | |
| 6 | |
| 7 #include <jni.h> | |
| 8 | |
| 9 #include "base/android/base_jni_registrar.h" | |
| 10 #include "base/android/jni_android.h" | |
| 11 #include "base/android/jni_registrar.h" | |
| 12 #include "base/message_loop/message_loop.h" | |
| 13 #include "jni/BaseRunLoop_jni.h" | |
| 14 #include "mojo/common/message_pump_mojo.h" | |
| 15 | |
| 16 namespace mojo { | |
| 17 namespace android { | |
| 18 | |
| 19 static jlong CreateBaseRunLoop(JNIEnv* env, jobject jcaller) { | |
| 20 base::MessageLoop* message_loop = | |
| 21 new base::MessageLoop(common::MessagePumpMojo::Create()); | |
| 22 return (uintptr_t) message_loop; | |
|
qsr
2015/02/05 16:50:07
Do not use C-cast. This should be a reinterpret_ca
etiennej
2015/02/06 16:22:29
Done.
| |
| 23 } | |
| 24 | |
| 25 static void Run(JNIEnv* env, jobject jcaller, jlong runLoopID) { | |
| 26 reinterpret_cast<base::MessageLoop*>(runLoopID)->Run(); | |
| 27 } | |
| 28 | |
| 29 static void RunUntilIdle(JNIEnv* env, jobject jcaller, jlong runLoopID) { | |
| 30 reinterpret_cast<base::MessageLoop*>(runLoopID)->RunUntilIdle(); | |
| 31 } | |
| 32 | |
| 33 static void Quit(JNIEnv* env, jobject jcaller, jlong runLoopID) { | |
| 34 reinterpret_cast<base::MessageLoop*>(runLoopID)->Quit(); | |
| 35 } | |
| 36 | |
| 37 static void PostDelayedTask(JNIEnv* env, | |
| 38 jobject jcaller, | |
| 39 jlong runLoopID, | |
| 40 jobject runnable, | |
| 41 jlong delay) { | |
| 42 /*Closure::Runnable* quit_runnable = | |
| 43 NewRunnableFromCallable(callable, loop_.QuitClosure()); | |
| 44 | |
| 45 loop_.PostDelayedTask( | |
| 46 FROM_HERE, base::Bind(&mojo::Closure::Run, | |
| 47 base::Owned(new mojo::Closure(quit_runnable))), | |
| 48 base::TimeDelta::FromMicroseconds(delay));*/ | |
|
qsr
2015/02/05 16:50:07
Either you do not need this method at all, or you
etiennej
2015/02/06 16:22:29
Sorry. Done.
| |
| 49 } | |
| 50 | |
| 51 static void DeleteMessageLoop(JNIEnv* env, jobject jcaller, jlong runLoopID) { | |
| 52 base::MessageLoop* message_loop = | |
| 53 reinterpret_cast<base::MessageLoop*>(runLoopID); | |
| 54 delete message_loop; | |
| 55 } | |
| 56 | |
| 57 bool RegisterBaseRunLoop(JNIEnv* env) { | |
| 58 return RegisterNativesImpl(env); | |
| 59 } | |
| 60 | |
| 61 } // namespace android | |
| 62 } // namespace mojo | |
| 63 | |
| 64 | |
| OLD | NEW |