Merge "Remove synchronized from static methods in WebView."

This commit is contained in:
TreeHugger Robot
2016-07-19 11:42:00 +00:00
committed by Android (Google) Code Review
6 changed files with 26 additions and 21 deletions

View File

@@ -35,7 +35,7 @@ public abstract class CookieManager {
*
* @return the singleton CookieManager instance
*/
public static synchronized CookieManager getInstance() {
public static CookieManager getInstance() {
return WebViewFactory.getProvider().getCookieManager();
}

View File

@@ -65,6 +65,7 @@ public final class CookieSyncManager extends WebSyncManager {
private static CookieSyncManager sRef;
private static boolean sGetInstanceAllowed = false;
private static final Object sLock = new Object();
private CookieSyncManager() {
super(null, null);
@@ -77,12 +78,14 @@ public final class CookieSyncManager extends WebSyncManager {
*
* @return CookieSyncManager
*/
public static synchronized CookieSyncManager getInstance() {
checkInstanceIsAllowed();
if (sRef == null) {
sRef = new CookieSyncManager();
public static CookieSyncManager getInstance() {
synchronized (sLock) {
checkInstanceIsAllowed();
if (sRef == null) {
sRef = new CookieSyncManager();
}
return sRef;
}
return sRef;
}
/**
@@ -90,12 +93,14 @@ public final class CookieSyncManager extends WebSyncManager {
* @param context
* @return CookieSyncManager
*/
public static synchronized CookieSyncManager createInstance(Context context) {
if (context == null) {
throw new IllegalArgumentException("Invalid context argument");
public static CookieSyncManager createInstance(Context context) {
synchronized (sLock) {
if (context == null) {
throw new IllegalArgumentException("Invalid context argument");
}
setGetInstanceIsAllowed();
return getInstance();
}
setGetInstanceIsAllowed();
return getInstance();
}
/**

View File

@@ -2322,7 +2322,7 @@ public class WebView extends AbsoluteLayout
}
}
private static synchronized WebViewFactoryProvider getFactory() {
private static WebViewFactoryProvider getFactory() {
return WebViewFactory.getProvider();
}