Commit 1c625ad3 authored by Gustav Sennton's avatar Gustav Sennton Committed by Commit Bot

Add WebViewChromiumAwInit class.

This is patch 1/3 to move everything protected under
WebViewChromiumFactoryProvider.mLock into WebViewChromiumAwInit.
Patches:
1. Create WebViewChromiumAwInit and some methods for down-stream use.
2.  Update the down-stream glue-layer to point to
WebViewChromiumAwInit methods.
3. Move code from WebViewChromiumFactoryProvider to
WebViewChromiumAwInit.

Bug: 807332
Change-Id: I346dc325f36f83a3bd20064617bd43aca9f48423
Reviewed-on: https://chromium-review.googlesource.com/895942
Commit-Queue: Gustav Sennton <gsennton@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534041}
parent 79e23fe6
...@@ -49,6 +49,7 @@ android_library("glue") { ...@@ -49,6 +49,7 @@ android_library("glue") {
"java/src/com/android/webview/chromium/WebIconDatabaseAdapter.java", "java/src/com/android/webview/chromium/WebIconDatabaseAdapter.java",
"java/src/com/android/webview/chromium/WebMessagePortAdapter.java", "java/src/com/android/webview/chromium/WebMessagePortAdapter.java",
"java/src/com/android/webview/chromium/WebStorageAdapter.java", "java/src/com/android/webview/chromium/WebStorageAdapter.java",
"java/src/com/android/webview/chromium/WebViewChromiumAwInit.java",
"java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java", "java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java",
"java/src/com/android/webview/chromium/WebViewChromiumFactoryProviderForO.java", "java/src/com/android/webview/chromium/WebViewChromiumFactoryProviderForO.java",
"java/src/com/android/webview/chromium/WebViewChromiumFactoryProviderForOMR1.java", "java/src/com/android/webview/chromium/WebViewChromiumFactoryProviderForOMR1.java",
......
// Copyright 2018 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 com.android.webview.chromium;
import org.chromium.android_webview.AwTracingController;
class WebViewChromiumAwInit {
private final WebViewChromiumFactoryProvider mFactory;
WebViewChromiumAwInit(WebViewChromiumFactoryProvider factory) {
mFactory = factory;
// Do not make calls into 'factory' in this ctor - this ctor is called from the
// WebViewChromiumFactoryProvider ctor, so 'factory' is not properly initialized yet.
}
// Allows down-stream to override this.
protected void startChromiumLocked() {}
AwTracingController getTracingControllerOnUiThread() {
synchronized (mFactory.mLock) {
mFactory.ensureChromiumStartedLocked(true);
return mFactory.getBrowserContextOnUiThread().getTracingController();
}
}
}
...@@ -124,6 +124,12 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { ...@@ -124,6 +124,12 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
mRunQueue.addTask(task); mRunQueue.addTask(task);
} }
/**
* Class that takes care of chromium lazy initialization.
* This is package-public so that a downstream subclass can access it.
*/
/* package */ WebViewChromiumAwInit mAwInit;
// Guards accees to the other members, and is notifyAll() signalled on the UI thread // Guards accees to the other members, and is notifyAll() signalled on the UI thread
// when the chromium process has been started. // when the chromium process has been started.
// This member is not private only because the downstream subclass needs to access it, // This member is not private only because the downstream subclass needs to access it,
...@@ -178,8 +184,14 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { ...@@ -178,8 +184,14 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
initialize(delegate); initialize(delegate);
} }
// Protected to allow downstream to override.
protected WebViewChromiumAwInit createAwInit(WebViewChromiumFactoryProvider provider) {
return new WebViewChromiumAwInit(provider);
}
@TargetApi(Build.VERSION_CODES.N) // For getSystemService() and isUserUnlocked(). @TargetApi(Build.VERSION_CODES.N) // For getSystemService() and isUserUnlocked().
private void initialize(WebViewDelegate webViewDelegate) { private void initialize(WebViewDelegate webViewDelegate) {
mAwInit = createAwInit(this);
mWebViewDelegate = webViewDelegate; mWebViewDelegate = webViewDelegate;
Context ctx = mWebViewDelegate.getApplication().getApplicationContext(); Context ctx = mWebViewDelegate.getApplication().getApplicationContext();
...@@ -368,6 +380,9 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { ...@@ -368,6 +380,9 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
private static final int DIR_RESOURCE_PAKS_ANDROID = 3003; private static final int DIR_RESOURCE_PAKS_ANDROID = 3003;
protected void startChromiumLocked() { protected void startChromiumLocked() {
// TODO(gsennton): remove this when down-stream is up-to-date:
// Call into the AwInit to allow down-stream to override startChromiumLocked
mAwInit.startChromiumLocked();
assert Thread.holdsLock(mLock) && ThreadUtils.runningOnUiThread(); assert Thread.holdsLock(mLock) && ThreadUtils.runningOnUiThread();
// The post-condition of this method is everything is ready, so notify now to cover all // The post-condition of this method is everything is ready, so notify now to cover all
......
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