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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/LauncherThread.java

Issue 2774363003: android: Java-based launcher thread (Closed)
Patch Set: Created 3 years, 9 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: 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());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698