Chromium Code Reviews| 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 a39909fd5222cb4f7210d55f8dd2c619eb79d267..ef49b97fd785cd13609ad5c11e28ea83f80a5d82 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 |
| @@ -39,6 +39,12 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer { |
| */ |
| public static final long RETRY_UPDATE_DURATION = TimeUnit.HOURS.toMillis(12L); |
| + /** |
| + * crbug.com/680128. Number of milliseconds between checks of updates for a WebAPK that is |
| + * expected to check updates less frequently. |
| + */ |
| + public static final long INFREQUENT_UPDATE_INTERVAL = TimeUnit.DAYS.toMillis(30L); |
| + |
| /** Data extracted from the WebAPK's launch intent and from the WebAPK's Android Manifest. */ |
| private WebApkInfo mInfo; |
| @@ -105,14 +111,14 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer { |
| if (!needsUpgrade) { |
| if (!mPreviousUpdateSucceeded) { |
| - recordUpdate(storage, true); |
| + recordUpdate(storage, true, null); |
| } |
| return; |
| } |
| // Set WebAPK update as having failed in case that Chrome is killed prior to |
| // {@link onBuiltWebApk} being called. |
| - recordUpdate(storage, false); |
| + recordUpdate(storage, false, null); |
| if (fetchedInfo != null) { |
| updateAsync(fetchedInfo, bestIconUrl, false /* isManifestStale */); |
| @@ -223,8 +229,11 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer { |
| if (isShellApkVersionOutOfDate(info)) return true; |
| long now = currentTimeMillis(); |
| + boolean isInfrequentUpdates = storage.getInfrequentUpdates(); |
| + long checkUpdatesInterval = isInfrequentUpdates ? INFREQUENT_UPDATE_INTERVAL |
| + : FULL_CHECK_UPDATE_INTERVAL; |
| long sinceLastCheckDurationMs = now - storage.getLastCheckForWebManifestUpdateTime(); |
| - if (sinceLastCheckDurationMs >= FULL_CHECK_UPDATE_INTERVAL) return true; |
| + if (sinceLastCheckDurationMs >= checkUpdatesInterval) return true; |
| long sinceLastUpdateRequestDurationMs = |
| now - storage.getLastWebApkUpdateRequestCompletionTime(); |
| @@ -236,11 +245,15 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer { |
| * Updates {@link WebappDataStorage} with the time of the latest WebAPK update and whether the |
| * WebAPK update succeeded. |
| */ |
| - private static void recordUpdate(WebappDataStorage storage, boolean success) { |
| + private static void recordUpdate(WebappDataStorage storage, boolean success, |
| + Boolean isInfrequentUpdates) { |
| // 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); |
| + if (isInfrequentUpdates != null) { |
| + storage.updateInfrequentUpdates(isInfrequentUpdates.booleanValue()); |
|
pkotwicz
2017/02/10 20:53:14
Nit: You should get the type conversion for free.
Xi Han
2017/02/13 22:56:14
Done.
|
| + } |
| } |
| /** |
| @@ -312,9 +325,9 @@ public class WebApkUpdateManager implements WebApkUpdateDataFetcher.Observer { |
| * fails. |
| */ |
| @CalledByNative |
| - private static void onBuiltWebApk(String id, boolean success) { |
| + private static void onBuiltWebApk(String id, boolean success, boolean isInfrequentUpdates) { |
| WebappDataStorage storage = WebappRegistry.getInstance().getWebappDataStorage(id); |
| - recordUpdate(storage, success); |
| + recordUpdate(storage, success, isInfrequentUpdates); |
| } |
| private static native void nativeUpdateAsync(String id, String startUrl, String scope, |