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

Side by Side 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, 4 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package com.android.webview.chromium; 5 package com.android.webview.chromium;
6 6
7 import android.webkit.WebViewDatabase; 7 import android.webkit.WebViewDatabase;
8 8
9 import org.chromium.android_webview.AwFormDatabase; 9 import org.chromium.android_webview.AwFormDatabase;
10 import org.chromium.android_webview.HttpAuthDatabase; 10 import org.chromium.android_webview.HttpAuthDatabase;
11 import org.chromium.base.ThreadUtils;
12
13 import java.util.concurrent.Callable;
11 14
12 /** 15 /**
13 * Chromium implementation of WebViewDatabase -- forwards calls to the 16 * Chromium implementation of WebViewDatabase -- forwards calls to the
14 * chromium internal implementation. 17 * chromium internal implementation.
15 */ 18 */
16 @SuppressWarnings("deprecation") 19 @SuppressWarnings("deprecation")
17 final class WebViewDatabaseAdapter extends WebViewDatabase { 20 final class WebViewDatabaseAdapter extends WebViewDatabase {
18 private HttpAuthDatabase mHttpAuthDatabase; 21 private final WebViewChromiumFactoryProvider mFactory;
22 private final HttpAuthDatabase mHttpAuthDatabase;
19 23
20 public WebViewDatabaseAdapter(HttpAuthDatabase httpAuthDatabase) { 24 public WebViewDatabaseAdapter(
25 WebViewChromiumFactoryProvider factory, HttpAuthDatabase httpAuthDat abase) {
26 mFactory = factory;
21 mHttpAuthDatabase = httpAuthDatabase; 27 mHttpAuthDatabase = httpAuthDatabase;
22 } 28 }
23 29
24 @Override 30 @Override
25 public boolean hasUsernamePassword() { 31 public boolean hasUsernamePassword() {
26 // This is a deprecated API: intentional no-op. 32 // This is a deprecated API: intentional no-op.
27 return false; 33 return false;
28 } 34 }
29 35
30 @Override 36 @Override
31 public void clearUsernamePassword() { 37 public void clearUsernamePassword() {
32 // This is a deprecated API: intentional no-op. 38 // This is a deprecated API: intentional no-op.
33 } 39 }
34 40
35 @Override 41 @Override
36 public boolean hasHttpAuthUsernamePassword() { 42 public boolean hasHttpAuthUsernamePassword() {
43 if (checkNeedsPost()) {
44 return mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
45 @Override
46 public Boolean call() {
47 return mHttpAuthDatabase.hasHttpAuthUsernamePassword();
48 }
49
50 });
51 }
37 return mHttpAuthDatabase.hasHttpAuthUsernamePassword(); 52 return mHttpAuthDatabase.hasHttpAuthUsernamePassword();
38 } 53 }
39 54
40 @Override 55 @Override
41 public void clearHttpAuthUsernamePassword() { 56 public void clearHttpAuthUsernamePassword() {
57 if (checkNeedsPost()) {
58 mFactory.addTask(new Runnable() {
59 @Override
60 public void run() {
61 mHttpAuthDatabase.clearHttpAuthUsernamePassword();
62 }
63
64 });
65 return;
66 }
42 mHttpAuthDatabase.clearHttpAuthUsernamePassword(); 67 mHttpAuthDatabase.clearHttpAuthUsernamePassword();
43 } 68 }
44 69
45 @Override 70 @Override
46 public boolean hasFormData() { 71 public boolean hasFormData() {
72 if (checkNeedsPost()) {
73 return mFactory.runOnUiThreadBlocking(new Callable<Boolean>() {
74 @Override
75 public Boolean call() {
76 return AwFormDatabase.hasFormData();
77 }
78
79 });
80 }
47 return AwFormDatabase.hasFormData(); 81 return AwFormDatabase.hasFormData();
48 } 82 }
49 83
50 @Override 84 @Override
51 public void clearFormData() { 85 public void clearFormData() {
86 if (checkNeedsPost()) {
87 mFactory.addTask(new Runnable() {
88 @Override
89 public void run() {
90 AwFormDatabase.clearFormData();
91 }
92
93 });
94 return;
95 }
52 AwFormDatabase.clearFormData(); 96 AwFormDatabase.clearFormData();
53 } 97 }
98
99 private static boolean checkNeedsPost() {
100 // Init is guaranteed to have happened if a WebViewDatabaseAdapter is cr eated, so do not
101 // need to check WebViewChromiumFactoryProvider.hasStarted.
102 return !ThreadUtils.runningOnUiThread();
103 }
54 } 104 }
OLDNEW
« 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