summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt2
-rw-r--r--core/java/android/webkit/WebViewDatabase.java2
-rw-r--r--core/java/android/webkit/WebViewDatabaseClassic.java13
-rw-r--r--core/java/android/webkit/WebViewFactory.java49
4 files changed, 36 insertions, 30 deletions
diff --git a/api/current.txt b/api/current.txt
index 0d09aa4..9dd67dd 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -27467,7 +27467,7 @@ package android.webkit {
method public void clearFormData();
method public void clearHttpAuthUsernamePassword();
method public void clearUsernamePassword();
- method public static synchronized android.webkit.WebViewDatabase getInstance(android.content.Context);
+ method public static android.webkit.WebViewDatabase getInstance(android.content.Context);
method public boolean hasFormData();
method public boolean hasHttpAuthUsernamePassword();
method public boolean hasUsernamePassword();
diff --git a/core/java/android/webkit/WebViewDatabase.java b/core/java/android/webkit/WebViewDatabase.java
index 62ec0d5..5597259 100644
--- a/core/java/android/webkit/WebViewDatabase.java
+++ b/core/java/android/webkit/WebViewDatabase.java
@@ -40,7 +40,7 @@ public class WebViewDatabase {
protected WebViewDatabase() {
}
- public static synchronized WebViewDatabase getInstance(Context context) {
+ public static WebViewDatabase getInstance(Context context) {
return WebViewFactory.getProvider().getWebViewDatabase(context);
}
diff --git a/core/java/android/webkit/WebViewDatabaseClassic.java b/core/java/android/webkit/WebViewDatabaseClassic.java
index c804b90..be01028 100644
--- a/core/java/android/webkit/WebViewDatabaseClassic.java
+++ b/core/java/android/webkit/WebViewDatabaseClassic.java
@@ -52,6 +52,7 @@ final class WebViewDatabaseClassic extends WebViewDatabase {
// implemented for b/5265606.
private static WebViewDatabaseClassic sInstance = null;
+ private static final Object sInstanceLock = new Object();
private static SQLiteDatabase sDatabase = null;
@@ -99,7 +100,7 @@ final class WebViewDatabaseClassic extends WebViewDatabase {
// Initially true until the background thread completes.
private boolean mInitialized = false;
- WebViewDatabaseClassic(final Context context) {
+ private WebViewDatabaseClassic(final Context context) {
JniUtil.setContext(context);
new Thread() {
@Override
@@ -111,11 +112,13 @@ final class WebViewDatabaseClassic extends WebViewDatabase {
// Singleton only, use getInstance()
}
- public static synchronized WebViewDatabaseClassic getInstance(Context context) {
- if (sInstance == null) {
- sInstance = new WebViewDatabaseClassic(context);
+ public static WebViewDatabaseClassic getInstance(Context context) {
+ synchronized (sInstanceLock) {
+ if (sInstance == null) {
+ sInstance = new WebViewDatabaseClassic(context);
+ }
+ return sInstance;
}
- return sInstance;
}
private synchronized void init(Context context) {
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java
index 2fc9b39..b833a01 100644
--- a/core/java/android/webkit/WebViewFactory.java
+++ b/core/java/android/webkit/WebViewFactory.java
@@ -41,36 +41,39 @@ class WebViewFactory {
// Cache the factory both for efficiency, and ensure any one process gets all webviews from the
// same provider.
private static WebViewFactoryProvider sProviderInstance;
+ private static final Object sProviderLock = new Object();
- static synchronized WebViewFactoryProvider getProvider() {
- // For now the main purpose of this function (and the factory abstraction) is to keep
- // us honest and minimize usage of WebViewClassic internals when binding the proxy.
- if (sProviderInstance != null) return sProviderInstance;
+ static WebViewFactoryProvider getProvider() {
+ synchronized (sProviderLock) {
+ // For now the main purpose of this function (and the factory abstraction) is to keep
+ // us honest and minimize usage of WebViewClassic internals when binding the proxy.
+ if (sProviderInstance != null) return sProviderInstance;
- // For debug builds, we allow a system property to specify that we should use the
- // Chromium powered WebView. This enables us to switch between implementations
- // at runtime. For user (release) builds, don't allow this.
- if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("webview.use_chromium", false)) {
- StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
- try {
- sProviderInstance = loadChromiumProvider();
- if (DEBUG) Log.v(LOGTAG, "Loaded Chromium provider: " + sProviderInstance);
- } finally {
- StrictMode.setThreadPolicy(oldPolicy);
+ // For debug builds, we allow a system property to specify that we should use the
+ // Chromium powered WebView. This enables us to switch between implementations
+ // at runtime. For user (release) builds, don't allow this.
+ if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("webview.use_chromium", false)) {
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+ try {
+ sProviderInstance = loadChromiumProvider();
+ if (DEBUG) Log.v(LOGTAG, "Loaded Chromium provider: " + sProviderInstance);
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
+ }
}
- }
- if (sProviderInstance == null) {
- if (DEBUG) Log.v(LOGTAG, "Falling back to default provider: "
- + DEFAULT_WEBVIEW_FACTORY);
- sProviderInstance = getFactoryByName(DEFAULT_WEBVIEW_FACTORY,
- WebViewFactory.class.getClassLoader());
if (sProviderInstance == null) {
- if (DEBUG) Log.v(LOGTAG, "Falling back to explicit linkage");
- sProviderInstance = new WebViewClassic.Factory();
+ if (DEBUG) Log.v(LOGTAG, "Falling back to default provider: "
+ + DEFAULT_WEBVIEW_FACTORY);
+ sProviderInstance = getFactoryByName(DEFAULT_WEBVIEW_FACTORY,
+ WebViewFactory.class.getClassLoader());
+ if (sProviderInstance == null) {
+ if (DEBUG) Log.v(LOGTAG, "Falling back to explicit linkage");
+ sProviderInstance = new WebViewClassic.Factory();
+ }
}
+ return sProviderInstance;
}
- return sProviderInstance;
}
// TODO: This allows us to have the legacy and Chromium WebView coexist for development