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

Unified Diff: base/android/java/src/org/chromium/base/JavaThread.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 copyright year, and split a comment over two lines Created 7 years, 5 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: base/android/java/src/org/chromium/base/JavaThread.java
diff --git a/base/android/java/src/org/chromium/base/JavaThread.java b/base/android/java/src/org/chromium/base/JavaThread.java
new file mode 100644
index 0000000000000000000000000000000000000000..9ab0f7de8404fe656b35cb278ade9ca9ebb12ff2
--- /dev/null
+++ b/base/android/java/src/org/chromium/base/JavaThread.java
@@ -0,0 +1,38 @@
+// 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;
+
+@JNINamespace("base::android")
+class JavaThread implements Handler.Callback {
+
+ final HandlerThread mThread;
+
+ private JavaThread(String name) {
+ mThread = new HandlerThread(name);
+ }
+
+ @CalledByNative
+ private static JavaThread create(String name) {
+ return new JavaThread(name);
benm (inactive) 2013/07/10 16:50:06 What is the lifetime of the thread? Will it loop f
Kristian Monsen 2013/07/10 17:50:19 Currently it lives forever since that is what is n
+ }
+
+ @CalledByNative
+ private void start(int nativeThread) {
+ mThread.start();
+ new Handler(mThread.getLooper(), this).sendEmptyMessage(nativeThread);
+ }
+
+ public boolean handleMessage(Message msg) {
benm (inactive) 2013/07/10 16:50:06 nit: @Override
Kristian Monsen 2013/07/10 17:50:19 Done.
+ nativeInitializeThread(msg.what);
+ return true;
+ }
+
+ private native void nativeInitializeThread(int nativeJavaThread);
+}

Powered by Google App Engine
This is Rietveld 408576698