Tidy up WebViewChromiumFactoryProvider.
Clarify log message about UI thread binding and move functions
to their correct place in the file structure.
Change-Id: I4c201ba9141590b71a492e975ae6e3f40ddbdef1
diff --git a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
index 07404e3..33d080d 100644
--- a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
+++ b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
@@ -56,6 +56,8 @@
public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
+ private final String TAG = "WebViewChromiumFactoryProvider";
+
private static final String CHROMIUM_PREFS_NAME = "WebViewChromiumPrefs";
private static final String COMMAND_LINE_FILE = "/data/local/tmp/webview-command-line";
@@ -101,8 +103,9 @@
}
Looper looper = !onMainThread ? Looper.myLooper() : Looper.getMainLooper();
- Log.v("WebViewChromium", "Binding Chromium to the " +
- (onMainThread ? "main":"background") + " looper " + looper);
+ Log.v(TAG, "Binding Chromium to " +
+ (Looper.getMainLooper().equals(looper) ? "main":"background") +
+ " looper " + looper);
ThreadUtils.setUiThread(looper);
if (ThreadUtils.runningOnUiThread()) {
@@ -196,6 +199,47 @@
mWebViewsToStart = null;
}
+ boolean hasStarted() {
+ return mStarted;
+ }
+
+ void startYourEngines(boolean onMainThread) {
+ synchronized (mLock) {
+ ensureChromiumStartedLocked(onMainThread);
+
+ }
+ }
+
+ AwBrowserContext getBrowserContext() {
+ synchronized (mLock) {
+ return getBrowserContextLocked();
+ }
+ }
+
+ private AwBrowserContext getBrowserContextLocked() {
+ assert Thread.holdsLock(mLock);
+ assert mStarted;
+ if (mBrowserContext == null) {
+ mBrowserContext = new AwBrowserContext(
+ ActivityThread.currentApplication().getSharedPreferences(
+ CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE));
+ }
+ return mBrowserContext;
+ }
+
+ private void setWebContentsDebuggingEnabled(boolean enable) {
+ if (Looper.myLooper() != ThreadUtils.getUiThreadLooper()) {
+ throw new RuntimeException(
+ "Toggling of Web Contents Debugging must be done on the UI thread");
+ }
+ if (mDevToolsServer == null) {
+ if (!enable) return;
+ mDevToolsServer = new AwDevToolsServer();
+ }
+ mDevToolsServer.setRemoteDebuggingEnabled(enable);
+ }
+
+
@Override
public Statics getStatics() {
synchronized (mLock) {
@@ -255,17 +299,6 @@
return wvc;
}
- boolean hasStarted() {
- return mStarted;
- }
-
- void startYourEngines(boolean onMainThread) {
- synchronized (mLock) {
- ensureChromiumStartedLocked(onMainThread);
-
- }
- }
-
@Override
public GeolocationPermissions getGeolocationPermissions() {
synchronized (mLock) {
@@ -278,23 +311,6 @@
return mGeolocationPermissions;
}
- AwBrowserContext getBrowserContext() {
- synchronized (mLock) {
- return getBrowserContextLocked();
- }
- }
-
- private AwBrowserContext getBrowserContextLocked() {
- assert Thread.holdsLock(mLock);
- assert mStarted;
- if (mBrowserContext == null) {
- mBrowserContext = new AwBrowserContext(
- ActivityThread.currentApplication().getSharedPreferences(
- CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE));
- }
- return mBrowserContext;
- }
-
@Override
public CookieManager getCookieManager() {
synchronized (mLock) {
@@ -341,16 +357,4 @@
}
return mWebViewDatabase;
}
-
- private void setWebContentsDebuggingEnabled(boolean enable) {
- if (Looper.myLooper() != ThreadUtils.getUiThreadLooper()) {
- throw new RuntimeException(
- "Toggling of Web Contents Debugging must be done on the UI thread");
- }
- if (mDevToolsServer == null) {
- if (!enable) return;
- mDevToolsServer = new AwDevToolsServer();
- }
- mDevToolsServer.setRemoteDebuggingEnabled(enable);
- }
}