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

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: 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
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..0758d2a5bbee8819d1caad7d485932ffc7cf5d71 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,20 @@ 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);
+ // Access the WebappDataStorage to force it to finish loading. A strict mode
+ // exception is thrown if the WebappDataStorage is accessed on the UI thread prior
+ // to the storage being fully loaded.
+ 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