| Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
|
| index 0b94233190d49444b56e9c72c3f22d6a1424df1b..c8dae5ee46e1273bc391671faffb611ca713418c 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java
|
| @@ -63,6 +63,9 @@ public class WebappDataStorage {
|
| // Whether to check updates less frequently.
|
| static final String KEY_RELAX_UPDATES = "relax_updates";
|
|
|
| + // The shell Apk version requested in the last update.
|
| + static final String KEY_LAST_REQUESTED_SHELL_APK_VERSION = "last_requested_shell_apk_version";
|
| +
|
| // Number of milliseconds between checks for whether the WebAPK's Web Manifest has changed.
|
| public static final long UPDATE_INTERVAL = TimeUnit.DAYS.toMillis(3L);
|
|
|
| @@ -74,6 +77,9 @@ public class WebappDataStorage {
|
| // server if the previous update attempt failed.
|
| public static final long RETRY_UPDATE_DURATION = TimeUnit.HOURS.toMillis(12L);
|
|
|
| + // The default shell Apk version of WebAPKs.
|
| + static final int DEFAULT_SHELL_APK_VERSION = 1;
|
| +
|
| // Unset/invalid constants for last used times and URLs. 0 is used as the null last used time as
|
| // WebappRegistry assumes that this is always a valid timestamp.
|
| static final long LAST_USED_UNSET = 0;
|
| @@ -435,6 +441,16 @@ public class WebappDataStorage {
|
| return mPreferences.getInt(KEY_UPDATE_REQUESTED, 0);
|
| }
|
|
|
| + /** Updates the shell Apk version requested in the last update. */
|
| + void updateLastRequestedShellApkVersion(int shellApkVersion) {
|
| + mPreferences.edit().putInt(KEY_LAST_REQUESTED_SHELL_APK_VERSION, shellApkVersion).apply();
|
| + }
|
| +
|
| + /** Returns the shell Apk version requested in last update. */
|
| + int getLastRequestedShellApkVersion() {
|
| + return mPreferences.getInt(KEY_LAST_REQUESTED_SHELL_APK_VERSION, DEFAULT_SHELL_APK_VERSION);
|
| + }
|
| +
|
| /**
|
| * Returns whether the previous WebAPK update attempt succeeded. Returns true if there has not
|
| * been any update attempts.
|
| @@ -467,7 +483,7 @@ public class WebappDataStorage {
|
| if (sinceLastCheckDurationMs >= checkUpdatesInterval) return true;
|
|
|
| long sinceLastUpdateRequestDurationMs = now - getLastWebApkUpdateRequestCompletionTime();
|
| - return sinceLastUpdateRequestDurationMs >= WebappDataStorage.RETRY_UPDATE_DURATION
|
| + return sinceLastUpdateRequestDurationMs >= RETRY_UPDATE_DURATION
|
| && !didPreviousUpdateSucceed();
|
| }
|
|
|
|
|