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

Unified Diff: base/android/java/src/org/chromium/base/JavaHandlerThread.java

Issue 18584006: Making a way to create thread with a Java Looper for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comment for TYPE_JAVA Created 7 years, 4 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
« no previous file with comments | « base/android/base_jni_registrar.cc ('k') | base/android/java_handler_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/JavaHandlerThread.java
diff --git a/base/android/java/src/org/chromium/base/JavaHandlerThread.java b/base/android/java/src/org/chromium/base/JavaHandlerThread.java
new file mode 100644
index 0000000000000000000000000000000000000000..1b84677d604c7cc2ff2cc8ca1c0476088a6df887
--- /dev/null
+++ b/base/android/java/src/org/chromium/base/JavaHandlerThread.java
@@ -0,0 +1,41 @@
+// Copyright (c) 2013 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.base;
+
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Message;
+
+/**
+ * This class is an internal detail of the native counterpart.
+ * It is instantiated and owned by the native object.
+ */
+@JNINamespace("base::android")
+class JavaHandlerThread {
+ final HandlerThread mThread;
+
+ private JavaHandlerThread(String name) {
+ mThread = new HandlerThread(name);
+ }
+
+ @CalledByNative
+ private static JavaHandlerThread create(String name) {
+ return new JavaHandlerThread(name);
+ }
+
+ @CalledByNative
+ private void start(final int nativeThread, final int nativeEvent) {
+ mThread.start();
+ new Handler(mThread.getLooper()).post(new Runnable() {
+ @Override
+ public void run() {
+ nativeInitializeThread(nativeThread, nativeEvent);
+ }
+ });
+ }
+
+ private native void nativeInitializeThread(int nativeJavaHandlerThread, int nativeEvent);
+}
« no previous file with comments | « base/android/base_jni_registrar.cc ('k') | base/android/java_handler_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698