Chromium Code Reviews| Index: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java |
| diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java |
| index 96120eabb8d59acc5f29df72cee5096f9eee9f32..ff466cee33a437991098af2070f984cf7778778d 100644 |
| --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java |
| +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java |
| @@ -36,12 +36,15 @@ import org.chromium.android_webview.AwContentsClient; |
| import org.chromium.android_webview.AwContentsStatics; |
| import org.chromium.android_webview.AwCookieManager; |
| import org.chromium.android_webview.AwDevToolsServer; |
| +import org.chromium.android_webview.AwGeolocationPermissions; |
| import org.chromium.android_webview.AwNetworkChangeNotifierRegistrationPolicy; |
| import org.chromium.android_webview.AwQuotaManagerBridge; |
| import org.chromium.android_webview.AwResource; |
| import org.chromium.android_webview.AwSettings; |
| +import org.chromium.android_webview.HttpAuthDatabase; |
| import org.chromium.android_webview.R; |
| import org.chromium.android_webview.ResourcesContextWrapperFactory; |
| +import org.chromium.base.BuildConfig; |
| import org.chromium.base.CommandLine; |
| import org.chromium.base.ContextUtils; |
| import org.chromium.base.MemoryPressureListener; |
| @@ -379,15 +382,14 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { |
| } |
| } |
| - AwBrowserContext getBrowserContext() { |
| - synchronized (mLock) { |
| - return getBrowserContextLocked(); |
| + // Only on UI thread. |
| + AwBrowserContext getBrowserContextOnUiThread() { |
| + assert mStarted; |
| + if (BuildConfig.IS_DEBUG && !ThreadUtils.runningOnUiThread()) { |
|
boliu
2016/07/27 05:30:26
the new way to do asserts..
boliu
2016/07/28 01:32:15
I'll rebase this onto https://codereview.chromium.
Torne
2016/07/28 11:47:12
So not objecting to this, but where did this "come
boliu
2016/07/28 13:49:38
Oh I just copied Ted's CL here: https://codereview
|
| + throw new RuntimeException( |
| + "getBrowserContextOnUiThread called on " + Thread.currentThread()); |
| } |
| - } |
| - private AwBrowserContext getBrowserContextLocked() { |
| - assert Thread.holdsLock(mLock); |
| - assert mStarted; |
| if (mBrowserContext == null) { |
| mBrowserContext = |
| new AwBrowserContext(mWebViewPrefs, ContextUtils.getApplicationContext()); |
| @@ -482,7 +484,12 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { |
| if (mGeolocationPermissions == null) { |
| ensureChromiumStartedLocked(true); |
| mGeolocationPermissions = new GeolocationPermissionsAdapter( |
| - getBrowserContextLocked().getGeolocationPermissions()); |
| + runOnUiThreadBlocking(new Callable<AwGeolocationPermissions>() { |
| + @Override |
| + public AwGeolocationPermissions call() { |
| + return getBrowserContextOnUiThread().getGeolocationPermissions(); |
| + } |
| + })); |
| } |
| } |
| return mGeolocationPermissions; |
| @@ -514,20 +521,30 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { |
| synchronized (mLock) { |
| if (mWebStorage == null) { |
| ensureChromiumStartedLocked(true); |
| - mWebStorage = new WebStorageAdapter(AwQuotaManagerBridge.getInstance()); |
| + mWebStorage = new WebStorageAdapter( |
| + runOnUiThreadBlocking(new Callable<AwQuotaManagerBridge>() { |
| + @Override |
| + public AwQuotaManagerBridge call() { |
| + return AwQuotaManagerBridge.getInstance(); |
| + } |
| + })); |
| } |
| } |
| return mWebStorage; |
| } |
| @Override |
| - public WebViewDatabase getWebViewDatabase(Context context) { |
| + public WebViewDatabase getWebViewDatabase(final Context context) { |
| synchronized (mLock) { |
| if (mWebViewDatabase == null) { |
| ensureChromiumStartedLocked(true); |
| - AwBrowserContext browserContext = getBrowserContextLocked(); |
| mWebViewDatabase = new WebViewDatabaseAdapter( |
| - browserContext.getHttpAuthDatabase(context)); |
| + runOnUiThreadBlocking(new Callable<HttpAuthDatabase>() { |
| + @Override |
| + public HttpAuthDatabase call() { |
| + return getBrowserContextOnUiThread().getHttpAuthDatabase(context); |
| + } |
| + })); |
| } |
| } |
| return mWebViewDatabase; |