Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6ff4784 authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Use less static synchronized" into jb-mr1-dev

parents a21ad1a3 9f9d3455
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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();
+1 −1
Original line number Diff line number Diff line
@@ -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);
    }

+8 −5
Original line number Diff line number Diff line
@@ -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,12 +112,14 @@ final class WebViewDatabaseClassic extends WebViewDatabase {
        // Singleton only, use getInstance()
    }

    public static synchronized WebViewDatabaseClassic getInstance(Context context) {
    public static WebViewDatabaseClassic getInstance(Context context) {
        synchronized (sInstanceLock) {
            if (sInstance == null) {
                sInstance = new WebViewDatabaseClassic(context);
            }
            return sInstance;
        }
    }

    private synchronized void init(Context context) {
        if (mInitialized) {
+26 −23
Original line number Diff line number Diff line
@@ -41,8 +41,10 @@ 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() {
    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;
@@ -72,6 +74,7 @@ class WebViewFactory {
            }
            return sProviderInstance;
        }
    }

    // TODO: This allows us to have the legacy and Chromium WebView coexist for development
    // and side-by-side testing. After transition, remove this when no longer required.