Commit 94e4c7f3 authored by Tobias Sargeant's avatar Tobias Sargeant Committed by Commit Bot

[aw] Provide a Handler on which platform service tasks can execute

Bug: 897266
Change-Id: Icc0f7b1671031f76e2781ed2e6e217c50f0925e6
Reviewed-on: https://chromium-review.googlesource.com/c/1292469Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarTobias Sargeant <tobiasjs@chromium.org>
Commit-Queue: Tobias Sargeant <tobiasjs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601676}
parent 1fe79f73
......@@ -5,6 +5,8 @@
package org.chromium.android_webview;
import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.annotation.NonNull;
import org.chromium.base.Callback;
......@@ -16,9 +18,14 @@ import org.chromium.base.ThreadUtils;
*/
public abstract class PlatformServiceBridge {
private static final String TAG = "PlatformServiceBrid-";
private static PlatformServiceBridge sInstance;
private static final Object sInstanceLock = new Object();
private static HandlerThread sHandlerThread;
private static Handler sHandler;
private static final Object sHandlerLock = new Object();
protected PlatformServiceBridge() {}
@SuppressWarnings("unused")
......@@ -43,6 +50,18 @@ public abstract class PlatformServiceBridge {
}
}
// Return a handler appropriate for executing blocking Platform Service tasks.
public static Handler getHandler() {
synchronized (sHandlerLock) {
if (sHandler == null) {
sHandlerThread = new HandlerThread("PlatformServiceBridgeHandlerThread");
sHandlerThread.start();
sHandler = new Handler(sHandlerThread.getLooper());
}
}
return sHandler;
}
// Can WebView use Google Play Services (a.k.a. GMS)?
public boolean canUseGms() {
return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment