Merge "Cache the parsed result of WebView provider config xml" into nyc-dev
This commit is contained in:
@@ -59,13 +59,19 @@ public class SystemImpl implements SystemInterface {
|
||||
private static final String TAG_AVAILABILITY = "availableByDefault";
|
||||
private static final String TAG_SIGNATURE = "signature";
|
||||
private static final String TAG_FALLBACK = "isFallback";
|
||||
private final WebViewProviderInfo[] mWebViewProviderPackages;
|
||||
|
||||
/**
|
||||
* Returns all packages declared in the framework resources as potential WebView providers.
|
||||
* @hide
|
||||
* */
|
||||
@Override
|
||||
public WebViewProviderInfo[] getWebViewPackages() {
|
||||
// Initialization-on-demand holder idiom for getting the WebView provider packages once and
|
||||
// for all in a thread-safe manner.
|
||||
private static class LazyHolder {
|
||||
private static final SystemImpl INSTANCE = new SystemImpl();
|
||||
}
|
||||
|
||||
public static SystemImpl getInstance() {
|
||||
return LazyHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private SystemImpl() {
|
||||
int numFallbackPackages = 0;
|
||||
int numAvailableByDefaultPackages = 0;
|
||||
int numAvByDefaultAndNotFallback = 0;
|
||||
@@ -135,7 +141,16 @@ public class SystemImpl implements SystemInterface {
|
||||
throw new AndroidRuntimeException("There must be at least one WebView package "
|
||||
+ "that is available by default and not a fallback");
|
||||
}
|
||||
return webViewProviders.toArray(new WebViewProviderInfo[webViewProviders.size()]);
|
||||
mWebViewProviderPackages =
|
||||
webViewProviders.toArray(new WebViewProviderInfo[webViewProviders.size()]);
|
||||
}
|
||||
/**
|
||||
* Returns all packages declared in the framework resources as potential WebView providers.
|
||||
* @hide
|
||||
* */
|
||||
@Override
|
||||
public WebViewProviderInfo[] getWebViewPackages() {
|
||||
return mWebViewProviderPackages;
|
||||
}
|
||||
|
||||
public int getFactoryPackageVersion(String packageName) throws NameNotFoundException {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class WebViewUpdateService extends SystemService {
|
||||
|
||||
public WebViewUpdateService(Context context) {
|
||||
super(context);
|
||||
mImpl = new WebViewUpdateServiceImpl(context, new SystemImpl());
|
||||
mImpl = new WebViewUpdateServiceImpl(context, SystemImpl.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -404,7 +404,7 @@ public class WebViewUpdateServiceImpl {
|
||||
}
|
||||
|
||||
|
||||
private class ProviderAndPackageInfo {
|
||||
private static class ProviderAndPackageInfo {
|
||||
public final WebViewProviderInfo provider;
|
||||
public final PackageInfo packageInfo;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user