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

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

Issue 2809293005: android: assert runningOnLauncherThread (Closed)
Patch Set: assert Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.os.Looper;
8 9
9 import org.chromium.base.JavaHandlerThread; 10 import org.chromium.base.JavaHandlerThread;
10 import org.chromium.base.annotations.CalledByNative; 11 import org.chromium.base.annotations.CalledByNative;
11 import org.chromium.base.annotations.JNINamespace; 12 import org.chromium.base.annotations.JNINamespace;
12 13
14 /** This is BrowserThread::PROCESS_LAUNCHER. It is available before native libra ry is loaded. */
13 @JNINamespace("content::android") 15 @JNINamespace("content::android")
14 final class LauncherThread { 16 public final class LauncherThread {
15 private static final JavaHandlerThread sThread = 17 private static final JavaHandlerThread sThread =
16 new JavaHandlerThread("Chrome_ProcessLauncherThread"); 18 new JavaHandlerThread("Chrome_ProcessLauncherThread");
17 private static final Handler sHandler; 19 private static final Handler sHandler;
18 static { 20 static {
19 sThread.maybeStart(); 21 sThread.maybeStart();
20 sHandler = new Handler(sThread.getLooper()); 22 sHandler = new Handler(sThread.getLooper());
21 } 23 }
22 24
23 static void post(Runnable r) { 25 public static void post(Runnable r) {
24 sHandler.post(r); 26 sHandler.post(r);
25 } 27 }
26 28
29 public static boolean runningOnLauncherThread() {
30 return sHandler.getLooper() == Looper.myLooper();
31 }
32
27 @CalledByNative 33 @CalledByNative
28 private static JavaHandlerThread getHandlerThread() { 34 private static JavaHandlerThread getHandlerThread() {
29 return sThread; 35 return sThread;
30 } 36 }
31 37
32 private LauncherThread() {} 38 private LauncherThread() {}
33 } 39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698