Merge "Remove synchronized from static methods in WebView."
This commit is contained in:
committed by
Android (Google) Code Review
commit
c1b775584d
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2322,7 +2322,7 @@ public class WebView extends AbsoluteLayout
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized WebViewFactoryProvider getFactory() {
|
||||
private static WebViewFactoryProvider getFactory() {
|
||||
return WebViewFactory.getProvider();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user