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

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

Issue 2935853002: [Android Refactor] Reland: Merge WebappDataStorage#LAST_USED_UNSET and LAST_USED_INVALID (Closed)
Patch Set: Merge branch 'master' into reland Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c8b2e8ddc10a190f4aa2b84d92012d6f199e749b..9c85fda3d5e709d921f9b00197216815577ed8d2 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
@@ -84,10 +84,9 @@ public class WebappDataStorage {
// 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;
- static final long LAST_USED_INVALID = -1;
+ // Invalid constants for timestamps and URLs. '0' is used as the invalid timestamp as
+ // WebappRegistry and WebApkUpdateManager assume that timestamps are always valid.
+ static final long TIMESTAMP_INVALID = 0;
static final String URL_INVALID = "";
static final int VERSION_INVALID = 0;
@@ -139,14 +138,8 @@ public class WebappDataStorage {
* Opens an instance of WebappDataStorage for the web app specified.
* @param webappId The ID of the web app.
*/
- static WebappDataStorage open(final String webappId) {
- final WebappDataStorage storage = sFactory.create(webappId);
- if (storage.getLastUsedTime() == LAST_USED_INVALID) {
- // If the last used time is invalid then ensure that there is no data in the
- // WebappDataStorage which needs to be cleaned up.
- assert storage.isEmpty();
- }
- return storage;
+ static WebappDataStorage open(String webappId) {
+ return sFactory.create(webappId);
}
/**
@@ -321,10 +314,7 @@ public class WebappDataStorage {
void clearHistory() {
SharedPreferences.Editor editor = mPreferences.edit();
- // The last used time is set to 0 to ensure that a valid value is always present.
- // If the web app is not launched prior to the next cleanup, then its remaining data will be
- // removed. Otherwise, the next launch from home screen will update the last used time.
- editor.putLong(KEY_LAST_USED, LAST_USED_UNSET);
+ editor.remove(KEY_LAST_USED);
editor.remove(KEY_URL);
editor.remove(KEY_SCOPE);
editor.remove(KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME);
@@ -364,7 +354,7 @@ public class WebappDataStorage {
* Returns the last used time of this object, or -1 if it is not stored.
*/
public long getLastUsedTime() {
- return mPreferences.getLong(KEY_LAST_USED, LAST_USED_INVALID);
+ return mPreferences.getLong(KEY_LAST_USED, TIMESTAMP_INVALID);
}
/**
@@ -406,7 +396,7 @@ public class WebappDataStorage {
* updated. This time needs to be set when the WebAPK is registered.
*/
private long getLastCheckForWebManifestUpdateTime() {
- return mPreferences.getLong(KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME, LAST_USED_INVALID);
+ return mPreferences.getLong(KEY_LAST_CHECK_WEB_MANIFEST_UPDATE_TIME, TIMESTAMP_INVALID);
}
/**
@@ -423,7 +413,7 @@ public class WebappDataStorage {
* This time needs to be set when the WebAPK is registered.
*/
long getLastWebApkUpdateRequestCompletionTime() {
- return mPreferences.getLong(KEY_LAST_UPDATE_REQUEST_COMPLETE_TIME, LAST_USED_INVALID);
+ return mPreferences.getLong(KEY_LAST_UPDATE_REQUEST_COMPLETE_TIME, TIMESTAMP_INVALID);
}
/**
@@ -485,7 +475,7 @@ public class WebappDataStorage {
*/
boolean didPreviousUpdateSucceed() {
long lastUpdateCompletionTime = getLastWebApkUpdateRequestCompletionTime();
- if (lastUpdateCompletionTime == WebappDataStorage.LAST_USED_INVALID) {
+ if (lastUpdateCompletionTime == TIMESTAMP_INVALID) {
return true;
}
return getDidLastWebApkUpdateRequestSucceed();
@@ -519,8 +509,4 @@ public class WebappDataStorage {
mPreferences = ContextUtils.getApplicationContext().getSharedPreferences(
SHARED_PREFS_FILE_PREFIX + webappId, Context.MODE_PRIVATE);
}
-
- private boolean isEmpty() {
- return mPreferences.getAll().isEmpty();
- }
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698