Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
index 01800a7f569708ccbc8e377d5762bb4af7e3faa9..2802dd3d1d4e1ea1e78bfd1c8f75ea0b42784a28 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java |
@@ -13,7 +13,6 @@ import org.chromium.base.ContextUtils; |
import org.chromium.base.annotations.CalledByNative; |
import org.chromium.chrome.browser.tab.Tab; |
import org.chromium.chrome.browser.util.IntentUtils; |
-import org.chromium.chrome.browser.webapps.WebappRegistry.FetchWebappDataStorageCallback; |
import org.chromium.webapk.lib.client.WebApkVersion; |
import org.chromium.webapk.lib.common.WebApkConstants; |
import org.chromium.webapk.lib.common.WebApkMetaDataKeys; |
@@ -67,32 +66,24 @@ public class WebApkUpdateManager implements ManifestUpgradeDetector.Callback { |
mUpgradeDetector = new ManifestUpgradeDetector(tab, info, metadata, this); |
- WebappRegistry.FetchWebappDataStorageCallback callback = |
- new WebappRegistry.FetchWebappDataStorageCallback() { |
- @Override |
- public void onWebappDataStorageRetrieved(WebappDataStorage storage) { |
- if (forceUpgrade(storage)) { |
- mForceUpgrade = true; |
- } |
- |
- // TODO(pkotwicz|hanxi): Request upgrade if ShellAPK version changes if |
- // ManifestUpgradeDetector cannot fetch the Web Manifest. For instance, the |
- // web developer may have removed the Web Manifest from their site. |
- // (http://crbug.com/639536) |
- |
- long sinceLastCheckDuration = System.currentTimeMillis() |
- - storage.getLastCheckForWebManifestUpdateTime(); |
- if (sinceLastCheckDuration > FULL_CHECK_UPDATE_INTERVAL || mForceUpgrade) { |
- if (mUpgradeDetector.start()) { |
- // crbug.com/636525. The timestamp of the last check for updated |
- // Web Manifest should be updated after the detector finds the |
- // Web Manifest, not when the detector is started. |
- storage.updateTimeOfLastCheckForUpdatedWebManifest(); |
- } |
- } |
- } |
- }; |
- WebappRegistry.getWebappDataStorage(info.id(), callback); |
+ WebappDataStorage storage = WebappRegistry.getInstance().getWebappDataStorage(info.id()); |
+ if (forceUpgrade(storage)) mForceUpgrade = true; |
+ |
+ // TODO(pkotwicz|hanxi): Request upgrade if ShellAPK version changes if |
+ // ManifestUpgradeDetector cannot fetch the Web Manifest. For instance, the |
+ // web developer may have removed the Web Manifest from their site. |
+ // (http://crbug.com/639536) |
+ |
+ long sinceLastCheckDuration = System.currentTimeMillis() |
+ - storage.getLastCheckForWebManifestUpdateTime(); |
+ if (sinceLastCheckDuration > FULL_CHECK_UPDATE_INTERVAL || mForceUpgrade) { |
+ if (mUpgradeDetector.start()) { |
+ // crbug.com/636525. The timestamp of the last check for updated |
+ // Web Manifest should be updated after the detector finds the |
+ // Web Manifest, not when the detector is started. |
+ storage.updateTimeOfLastCheckForUpdatedWebManifest(); |
+ } |
+ } |
} |
@Override |
@@ -160,16 +151,12 @@ public class WebApkUpdateManager implements ManifestUpgradeDetector.Callback { |
*/ |
@CalledByNative |
private static void onBuiltWebApk(final boolean success, String webapkPackage) { |
- WebappRegistry.getWebappDataStorage(WebApkConstants.WEBAPK_ID_PREFIX + webapkPackage, |
- new FetchWebappDataStorageCallback() { |
- @Override |
- public void onWebappDataStorageRetrieved(WebappDataStorage storage) { |
- // Update the request time and result together. It prevents getting a |
- // correct request time but a result from the previous request. |
- storage.updateTimeOfLastWebApkUpdateRequestCompletion(); |
- storage.updateDidLastWebApkUpdateRequestSucceed(success); |
- } |
- }); |
+ WebappDataStorage storage = WebappRegistry.getInstance().getWebappDataStorage( |
+ WebApkConstants.WEBAPK_ID_PREFIX + webapkPackage); |
+ // Update the request time and result together. It prevents getting a |
+ // correct request time but a result from the previous request. |
+ storage.updateTimeOfLastWebApkUpdateRequestCompletion(); |
+ storage.updateDidLastWebApkUpdateRequestSucceed(success); |
} |
private static native void nativeUpdateAsync(String startUrl, String scope, String name, |