| Index: shell/android/apk/src/org/chromium/mojo/shell/NativeHandlerThread.java
|
| diff --git a/shell/android/apk/src/org/chromium/mojo/shell/NativeHandlerThread.java b/shell/android/apk/src/org/chromium/mojo/shell/NativeHandlerThread.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..334372ebd9995acea71635798269d6fc81c3aef8
|
| --- /dev/null
|
| +++ b/shell/android/apk/src/org/chromium/mojo/shell/NativeHandlerThread.java
|
| @@ -0,0 +1,54 @@
|
| +// 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.shell;
|
| +
|
| +import android.os.HandlerThread;
|
| +
|
| +import org.chromium.base.JNINamespace;
|
| +
|
| +/**
|
| + * Handler thread associated with a native message loop.
|
| + */
|
| +@JNINamespace("shell")
|
| +public class NativeHandlerThread extends HandlerThread {
|
| + // The native message loop.
|
| + private long mNativeMessageLoop = 0;
|
| +
|
| + /**
|
| + * Constructor.
|
| + */
|
| + public NativeHandlerThread(String name) {
|
| + super(name);
|
| + }
|
| +
|
| + /**
|
| + * @see HandlerThread#run()
|
| + */
|
| + @Override
|
| + public void run() {
|
| + try {
|
| + super.run();
|
| + } finally {
|
| + if (mNativeMessageLoop != 0) {
|
| + nativeDeleteMessageLoop(mNativeMessageLoop);
|
| + }
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * @see HandlerThread#onLooperPrepared()
|
| + */
|
| + @Override
|
| + protected void onLooperPrepared() {
|
| + if (mNativeMessageLoop == 0) {
|
| + mNativeMessageLoop = nativeCreateMessageLoop();
|
| + }
|
| + super.onLooperPrepared();
|
| + }
|
| +
|
| + native long nativeCreateMessageLoop();
|
| +
|
| + native void nativeDeleteMessageLoop(long messageLoop);
|
| +}
|
|
|