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

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

Issue 2935853002: [Android Refactor] Reland: Merge WebappDataStorage#LAST_USED_UNSET and LAST_USED_INVALID (Closed)
Patch Set: ABCD 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
Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java
index 1997ce97f279cb9b1ced3daafedd907400a81a4b..b05ebdcbdf2a63686a4bb0f6b904d1ab698ba2e2 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappRegistry.java
@@ -112,13 +112,19 @@ public class WebappRegistry {
protected final WebappDataStorage doInBackground(Void... nothing) {
// Create the WebappDataStorage on the background thread, as this must create and
// open a new SharedPreferences.
- return WebappDataStorage.open(webappId);
+ WebappDataStorage storage = WebappDataStorage.open(webappId);
+ // The first read from {@link WebappDataStorage} must be done in the background.
dominickn 2017/06/13 01:36:57 This is an interesting restriction! Is it new?
pkotwicz 2017/06/13 03:14:29 Thank you for your question! It forced me to do mo
dominickn 2017/06/13 23:13:21 Perhaps this bit of code should be moved to warmUp
+ // Otherwise a strict mode exception is thrown. Do it now.
+ storage.getLastUsedTime();
+ return storage;
}
@Override
protected final void onPostExecute(WebappDataStorage storage) {
- // Guarantee that last used time != WebappDataStorage.LAST_USED_INVALID. Must be
- // run on the main thread as SharedPreferences.Editor.apply() is called.
+ // Update the last used time in order to prevent
+ // {@link WebappRegistry@unregisterOldWebapps()} from deleting the
+ // WebappDataStorage. Must be run on the main thread as
+ // SharedPreferences.Editor.apply() is called.
mStorages.put(webappId, storage);
mPreferences.edit().putStringSet(KEY_WEBAPP_SET, mStorages.keySet()).apply();
storage.updateLastUsedTime();

Powered by Google App Engine
This is Rietveld 408576698