Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.base; | |
| 6 | |
| 7 import android.os.Handler; | |
| 8 import android.os.HandlerThread; | |
| 9 import android.os.Looper; | |
| 10 import android.os.Message; | |
| 11 | |
| 12 @JNINamespace("base::android") | |
| 13 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.
| |
| 14 | |
| 15 final HandlerThread mThread; | |
| 16 | |
| 17 private JavaThread(String name) { | |
| 18 mThread = new HandlerThread(name); | |
| 19 } | |
| 20 | |
| 21 @CalledByNative | |
| 22 private static JavaThread create(String name) { | |
| 23 return new JavaThread(name); | |
| 24 } | |
| 25 | |
| 26 @CalledByNative | |
| 27 private void start(int nativeThread) { | |
| 28 mThread.start(); | |
| 29 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
| |
| 30 } | |
| 31 | |
| 32 @Override | |
| 33 public boolean handleMessage(Message msg) { | |
| 34 nativeInitializeThread(msg.what); | |
| 35 return true; | |
| 36 } | |
| 37 | |
| 38 private native void nativeInitializeThread(int nativeJavaThread); | |
| 39 } | |
| OLD | NEW |