Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(797)

Unified Diff: mojo/android/system/src/org/chromium/mojo/system/impl/BaseRunLoop.java

Issue 898853006: Java content handler for Android. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/android/system/src/org/chromium/mojo/system/impl/BaseRunLoop.java
diff --git a/mojo/android/system/src/org/chromium/mojo/system/impl/BaseRunLoop.java b/mojo/android/system/src/org/chromium/mojo/system/impl/BaseRunLoop.java
new file mode 100644
index 0000000000000000000000000000000000000000..11d23af306592bef18df580237ca3cad4aff468e
--- /dev/null
+++ b/mojo/android/system/src/org/chromium/mojo/system/impl/BaseRunLoop.java
@@ -0,0 +1,67 @@
+// 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.
+
+package org.chromium.mojo.system.impl;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+import org.chromium.mojo.system.RunLoop;
+
+import java.lang.Runnable;
+
+/**
+ * Implementation of {@link RunLoop} suitable for the base:: message loop implementation.
+ */
+@JNINamespace("mojo::android")
+class BaseRunLoop implements RunLoop {
+ /**
+ * Pointer to the C run loop.
+ */
+ private long mRunLoopID;
+
+ private BaseRunLoop() {
+ this.mRunLoopID = nativeCreateBaseRunLoop();
+ }
+
+ public static RunLoop create() {
+ return new BaseRunLoop();
+ }
+
+ @Override
+ public void run() {
+ nativeRun(mRunLoopID);
+ }
+
+ @Override
+ public void runUntilIdle() {
+ nativeRunUntilIdle(mRunLoopID);
+ }
+
+ @Override
+ public void quit() {
+ nativeQuit(mRunLoopID);
+ }
+
+ @Override
+ public void postDelayedTask(Runnable runnable, long delay) {
+ nativePostDelayedTask(mRunLoopID, runnable, delay);
+ }
+
+ @Override
+ public void close() {
+ nativeDeleteMessageLoop(mRunLoopID);
qsr 2015/02/06 17:16:14 You need the close to notify CoreImpl so that here
etiennej 2015/02/09 14:09:51 Added a method in Core to close the run loop.
+ }
+
+ @CalledByNative
+ private static void runRunnable(Runnable runnable) {
+ runnable.run();
+ }
+
+ private native long nativeCreateBaseRunLoop();
+ private native void nativeRun(long runLoopID);
+ private native void nativeRunUntilIdle(long runLoopID);
+ private native void nativeQuit(long runLoopID);
+ private native void nativePostDelayedTask(long runLoopID, Runnable runnable, long delay);
+ private native void nativeDeleteMessageLoop(long runLoopID);
+}

Powered by Google App Engine
This is Rietveld 408576698