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..884f5318efab1be14520dd10f8e60668dc3da515 |
--- /dev/null |
+++ b/base/android/java/src/org/chromium/base/JavaThread.java |
@@ -0,0 +1,39 @@ |
+// 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 { |
joth
2013/07/10 20:33:48
comment? It's mainly an implementation detail of t
Kristian Monsen
2013/07/16 21:54:41
See below.
joth
2013/07/17 16:29:18
Cool.
I was actually meaning add a class comment
/
Kristian Monsen
2013/07/17 21:02:37
Done.
|
+ |
+ final HandlerThread mThread; |
+ |
+ private JavaThread(String name) { |
+ mThread = new HandlerThread(name); |
+ } |
+ |
+ @CalledByNative |
+ private static JavaThread create(String name) { |
+ return new JavaThread(name); |
+ } |
+ |
+ @CalledByNative |
+ private void start(int nativeThread) { |
+ mThread.start(); |
+ new Handler(mThread.getLooper(), this).sendEmptyMessage(nativeThread); |
joth
2013/07/10 20:33:48
rather than have the outer class subclass Handler.
Kristian Monsen
2013/07/16 21:54:41
Done. Removed the other parts that are no longer n
|
+ } |
+ |
+ @Override |
+ public boolean handleMessage(Message msg) { |
+ nativeInitializeThread(msg.what); |
+ return true; |
+ } |
+ |
+ private native void nativeInitializeThread(int nativeJavaThread); |
+} |