Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java

Issue 2184913005: Add calls to the server to request WebAPK updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and nits. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..dfdf7b62ad9eaa18d310af98679a9c01a2b7b3eb 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 checked for Web Manifest updates for a WebAPK.
+ 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).
+ static final String KEY_LAST_WEBAPK_UPDATE_REQUEST_COMPLETE_TIME =
+ "last_webapk_update_request_complete_time";
+
+ // Whether the last WebAPK update request succeeded.
+ static final String KEY_DID_LAST_WEBAPK_UPDATE_REQUEST_SUCCEED =
+ "did_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_DID_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 succeeded.
+ */
+ void updateDidLastWebApkUpdateRequestSucceed(boolean sucess) {
+ mPreferences.edit()
+ .putBoolean(KEY_DID_LAST_WEBAPK_UPDATE_REQUEST_SUCCEED, sucess)
+ .apply();
+ }
+
+ /**
+ * Returns whether the last update request to WebAPK Server succeeded.
+ */
+ boolean getDidLastWebApkUpdateRequestSucceed() {
+ return mPreferences.getBoolean(KEY_DID_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).
*/

Powered by Google App Engine
This is Rietveld 408576698