am e6ff4784: Merge "Use less static synchronized" into jb-mr1-dev
* commit 'e6ff47840fc6d8ac5ba551101684011e328b4caa': Use less static synchronized
This commit is contained in:
@@ -27471,7 +27471,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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user