Index: mojo/android/system/base_run_loop.cc |
diff --git a/mojo/android/system/base_run_loop.cc b/mojo/android/system/base_run_loop.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..517b2f45d2789ca74931cb407ea35ec5bd9bc20b |
--- /dev/null |
+++ b/mojo/android/system/base_run_loop.cc |
@@ -0,0 +1,64 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "mojo/android/system/base_run_loop.h" |
+ |
+#include <jni.h> |
+ |
+#include "base/android/base_jni_registrar.h" |
+#include "base/android/jni_android.h" |
+#include "base/android/jni_registrar.h" |
+#include "base/message_loop/message_loop.h" |
+#include "jni/BaseRunLoop_jni.h" |
+#include "mojo/common/message_pump_mojo.h" |
+ |
+namespace mojo { |
+namespace android { |
+ |
+static jlong CreateBaseRunLoop(JNIEnv* env, jobject jcaller) { |
+ base::MessageLoop* message_loop = |
+ new base::MessageLoop(common::MessagePumpMojo::Create()); |
+ 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.
|
+} |
+ |
+static void Run(JNIEnv* env, jobject jcaller, jlong runLoopID) { |
+ reinterpret_cast<base::MessageLoop*>(runLoopID)->Run(); |
+} |
+ |
+static void RunUntilIdle(JNIEnv* env, jobject jcaller, jlong runLoopID) { |
+ reinterpret_cast<base::MessageLoop*>(runLoopID)->RunUntilIdle(); |
+} |
+ |
+static void Quit(JNIEnv* env, jobject jcaller, jlong runLoopID) { |
+ reinterpret_cast<base::MessageLoop*>(runLoopID)->Quit(); |
+} |
+ |
+static void PostDelayedTask(JNIEnv* env, |
+ jobject jcaller, |
+ jlong runLoopID, |
+ jobject runnable, |
+ jlong delay) { |
+ /*Closure::Runnable* quit_runnable = |
+ NewRunnableFromCallable(callable, loop_.QuitClosure()); |
+ |
+ loop_.PostDelayedTask( |
+ FROM_HERE, base::Bind(&mojo::Closure::Run, |
+ base::Owned(new mojo::Closure(quit_runnable))), |
+ 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.
|
+} |
+ |
+static void DeleteMessageLoop(JNIEnv* env, jobject jcaller, jlong runLoopID) { |
+ base::MessageLoop* message_loop = |
+ reinterpret_cast<base::MessageLoop*>(runLoopID); |
+ delete message_loop; |
+} |
+ |
+bool RegisterBaseRunLoop(JNIEnv* env) { |
+ return RegisterNativesImpl(env); |
+} |
+ |
+} // namespace android |
+} // namespace mojo |
+ |
+ |