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 29cb18fcc650fafd93f2b9bed62fcd7ea80a5f94..1c816dd7bdb34936dc527f1b0f3e49c4997a9461 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 |
@@ -46,6 +46,19 @@ public class WebappDataStorage { |
static final String KEY_VERSION = "version"; |
static final String KEY_WEBAPK_PACKAGE_NAME = "webapk_package_name"; |
+ // The last time that Chrome checks Web Manifest updates for a WebAPK. |
pkotwicz
2016/08/11 22:02:44
How about: "The last time that Chrome checked for
Xi Han
2016/08/15 21:38:45
Done.
|
+ public static final String KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME = |
+ "last_check_web_manifest_update_time"; |
+ |
+ // The last time that the WebAPK update request completed (successfully or |
+ // unsuccessfully). |
+ public static final String KEY_LAST_WEBAPK_UPDATE_REQUEST_COMPLETE_TIME = |
+ "last_webapk_update_request_complete_time"; |
+ |
+ // Whether the last WebAPK update request succeeds. |
pkotwicz
2016/08/11 22:02:43
Nit: succeeds -> succeeded
Xi Han
2016/08/15 21:38:45
Done.
|
+ public static final String KEY_DOES_LAST_WEBAPK_UPDATE_REQUEST_SUCCEED = |
+ "does_last_webapk_update_request_succeed"; |
+ |
// 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; |
@@ -166,7 +179,7 @@ public class WebappDataStorage { |
} |
/** |
- * Deletes the URL and scope, and sets last used time to 0 in SharedPreferences. |
+ * Deletes the URL and scope, and sets all timestamps to 0 in SharedPreferences. |
* This does not remove the stored splash screen image (if any) for the app. |
* @param context The context to read the SharedPreferences file. |
* @param webappId The ID of the web app for which history is being cleared. |
@@ -181,6 +194,9 @@ public class WebappDataStorage { |
editor.putLong(KEY_LAST_USED, LAST_USED_UNSET); |
editor.remove(KEY_URL); |
editor.remove(KEY_SCOPE); |
+ editor.remove(KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME); |
+ editor.remove(KEY_LAST_WEBAPK_UPDATE_REQUEST_COMPLETE_TIME); |
+ editor.remove(KEY_DOES_LAST_WEBAPK_UPDATE_REQUEST_SUCCEED); |
editor.apply(); |
} |
@@ -401,6 +417,56 @@ public class WebappDataStorage { |
} |
/** |
+ * Updates the time of the last check for whether the WebAPK's Web Manifest was updated. |
+ */ |
+ void updateTimeOfLastCheckForUpdatedWebManifest() { |
+ mPreferences.edit() |
+ .putLong(KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME, sClock.currentTimeMillis()) |
+ .apply(); |
+ } |
+ |
+ /** |
+ * Returns the time of the last check for whether the WebAPK's Web Manifest was updated. |
+ */ |
+ long getLastCheckForWebManifestUpdateTime() { |
+ return mPreferences.getLong(KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME, LAST_USED_INVALID); |
+ } |
+ |
+ /** |
+ * Updates the time that the last WebAPK update request completed (successfully or |
+ * unsuccessfully). |
+ */ |
+ void updateTimeOfLastWebApkUpdateRequestCompletion() { |
+ mPreferences.edit() |
+ .putLong(KEY_LAST_WEBAPK_UPDATE_REQUEST_COMPLETE_TIME, sClock.currentTimeMillis()) |
+ .apply(); |
+ } |
+ |
+ /** |
+ * Returns the time that the last WebAPK update request completed (successfully or |
+ * unsuccessfully). |
+ */ |
+ long getLastWebApkUpdateRequestCompletionTime() { |
+ return mPreferences.getLong( |
+ KEY_LAST_WEBAPK_UPDATE_REQUEST_COMPLETE_TIME, LAST_USED_INVALID); |
+ } |
+ |
+ /** |
+ * Updates the result of whether the last update request to WebAPK Server succeeds. |
pkotwicz
2016/08/11 22:02:44
Nits:
- "succeeds" -> "succeeded"
- updateDoesLast
Xi Han
2016/08/15 21:38:45
Done.
|
+ */ |
+ void updateDoesLastWebApkUpdateRequestSucceed(boolean sucess) { |
+ mPreferences.edit() |
+ .putBoolean(KEY_DOES_LAST_WEBAPK_UPDATE_REQUEST_SUCCEED, sucess) |
+ .apply(); |
+ } |
+ |
+ /** |
+ * Returns whether the last update request to WebAPK Server succeeds. |
pkotwicz
2016/08/11 22:02:44
Nits:
- "succeeds" -> "succeeded"
- getDoesLastWeb
Xi Han
2016/08/15 21:38:45
Done.
|
+ */ |
+ boolean getDoesLastWebApkUpdateRequestSucceed() { |
+ return mPreferences.getBoolean(KEY_DOES_LAST_WEBAPK_UPDATE_REQUEST_SUCCEED, false); |
+ } |
+ /** |
* Returns true if this web app has been launched from home screen recently (within |
* WEBAPP_LAST_OPEN_MAX_TIME milliseconds). |
*/ |