Index: content/public/android/java/src/org/chromium/content/browser/LauncherThread.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/LauncherThread.java b/content/public/android/java/src/org/chromium/content/browser/LauncherThread.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2f3077690546d3819ffd04d913fff8a649a3b416 |
--- /dev/null |
+++ b/content/public/android/java/src/org/chromium/content/browser/LauncherThread.java |
@@ -0,0 +1,44 @@ |
+// Copyright 2017 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.content.browser; |
+ |
+import android.os.Handler; |
+ |
+import org.chromium.base.JavaHandlerThread; |
+import org.chromium.base.annotations.CalledByNative; |
+import org.chromium.base.annotations.JNINamespace; |
+ |
+@JNINamespace("content::android") |
+class LauncherThread { |
+ private static final Object sInstanceLock = new Object(); |
+ private static LauncherThread sInstance; |
+ |
+ static LauncherThread getInstance() { |
+ synchronized (sInstanceLock) { |
agrieve
2017/03/28 19:59:32
There's no reason to use this class without creati
boliu
2017/03/28 23:30:52
Done.
|
+ if (sInstance == null) { |
+ sInstance = new LauncherThread(); |
+ } |
+ } |
+ return sInstance; |
+ } |
+ |
+ static void post(Runnable r) { |
+ getInstance().mHandler.post(r); |
+ } |
+ |
+ @CalledByNative |
+ private static JavaHandlerThread getHandlerThread() { |
+ return getInstance().mThread; |
+ } |
+ |
+ private final JavaHandlerThread mThread; |
+ private final Handler mHandler; |
+ |
+ private LauncherThread() { |
+ mThread = new JavaHandlerThread("Chrome_ProcessLauncherThread"); |
+ mThread.maybeStart(); |
+ mHandler = new Handler(mThread.getLooper()); |
+ } |
+} |