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

Unified Diff: android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java

Issue 2191053002: aw: Fix WebViewDatabaseAdapter threading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java
index 972a619f7507fc980d02c322f03825035e4d5ea6..945fb68b11f059fb5fbcba267934b7e90f53f1e7 100644
--- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java
+++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java
@@ -8,6 +8,9 @@ import android.webkit.WebViewDatabase;
import org.chromium.android_webview.AwFormDatabase;
import org.chromium.android_webview.HttpAuthDatabase;
+import org.chromium.base.ThreadUtils;
+
+import java.util.concurrent.Callable;
/**
* Chromium implementation of WebViewDatabase -- forwards calls to the
@@ -15,9 +18,12 @@ import org.chromium.android_webview.HttpAuthDatabase;
*/
@SuppressWarnings("deprecation")
final class WebViewDatabaseAdapter extends WebViewDatabase {
- private HttpAuthDatabase mHttpAuthDatabase;
+ private final WebViewChromiumFactoryProvider mFactory;
+ private final HttpAuthDatabase mHttpAuthDatabase;
- public WebViewDatabaseAdapter(HttpAuthDatabase httpAuthDatabase) {
+ public WebViewDatabaseAdapter(
+ WebViewChromiumFactoryProvider factory, HttpAuthDatabase httpAuthDatabase) {
+ mFactory = factory;
mHttpAuthDatabase = httpAuthDatabase;
}
@@ -34,21 +40,65 @@ final class WebViewDatabaseAdapter extends WebViewDatabase {
@Override
public boolean hasHttpAuthUsernamePassword() {
+ if (checkNeedsPost()) {
+ return mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return mHttpAuthDatabase.hasHttpAuthUsernamePassword();
+ }
+
+ });
+ }
return mHttpAuthDatabase.hasHttpAuthUsernamePassword();
}
@Override
public void clearHttpAuthUsernamePassword() {
+ if (checkNeedsPost()) {
+ mFactory.addTask(new Runnable() {
+ @Override
+ public void run() {
+ mHttpAuthDatabase.clearHttpAuthUsernamePassword();
+ }
+
+ });
+ return;
+ }
mHttpAuthDatabase.clearHttpAuthUsernamePassword();
}
@Override
public boolean hasFormData() {
+ if (checkNeedsPost()) {
+ return mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return AwFormDatabase.hasFormData();
+ }
+
+ });
+ }
return AwFormDatabase.hasFormData();
}
@Override
public void clearFormData() {
+ if (checkNeedsPost()) {
+ mFactory.addTask(new Runnable() {
+ @Override
+ public void run() {
+ AwFormDatabase.clearFormData();
+ }
+
+ });
+ return;
+ }
AwFormDatabase.clearFormData();
}
+
+ private static boolean checkNeedsPost() {
+ // Init is guaranteed to have happened if a WebViewDatabaseAdapter is created, so do not
+ // need to check WebViewChromiumFactoryProvider.hasStarted.
+ return !ThreadUtils.runningOnUiThread();
+ }
}
« no previous file with comments | « android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698