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

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

Issue 2928993004: Revert of [Android Refactor] Merge WebappDataStorage#LAST_USED_UNSET and LAST_USED_INVALID (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.webapps; 5 package org.chromium.chrome.browser.webapps;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.SharedPreferences; 8 import android.content.SharedPreferences;
9 import android.content.pm.PackageManager; 9 import android.content.pm.PackageManager;
10 import android.os.AsyncTask; 10 import android.os.AsyncTask;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 new AsyncTask<Void, Void, WebappDataStorage>() { 110 new AsyncTask<Void, Void, WebappDataStorage>() {
111 @Override 111 @Override
112 protected final WebappDataStorage doInBackground(Void... nothing) { 112 protected final WebappDataStorage doInBackground(Void... nothing) {
113 // Create the WebappDataStorage on the background thread, as thi s must create and 113 // Create the WebappDataStorage on the background thread, as thi s must create and
114 // open a new SharedPreferences. 114 // open a new SharedPreferences.
115 return WebappDataStorage.open(webappId); 115 return WebappDataStorage.open(webappId);
116 } 116 }
117 117
118 @Override 118 @Override
119 protected final void onPostExecute(WebappDataStorage storage) { 119 protected final void onPostExecute(WebappDataStorage storage) {
120 // Update the last used time in order to prevent 120 // Guarantee that last used time != WebappDataStorage.LAST_USED_ INVALID. Must be
121 // {@link WebappRegistry@unregisterOldWebapps()} from deleting t he 121 // run on the main thread as SharedPreferences.Editor.apply() is called.
122 // WebappDataStorage. Must be run on the main thread as
123 // SharedPreferences.Editor.apply() is called.
124 mStorages.put(webappId, storage); 122 mStorages.put(webappId, storage);
125 mPreferences.edit().putStringSet(KEY_WEBAPP_SET, mStorages.keySe t()).apply(); 123 mPreferences.edit().putStringSet(KEY_WEBAPP_SET, mStorages.keySe t()).apply();
126 storage.updateLastUsedTime(); 124 storage.updateLastUsedTime();
127 if (callback != null) callback.onWebappDataStorageRetrieved(stor age); 125 if (callback != null) callback.onWebappDataStorageRetrieved(stor age);
128 } 126 }
129 }.execute(); 127 }.execute();
130 } 128 }
131 129
132 /** 130 /**
133 * Returns the WebappDataStorage object for webappId, or null if one cannot be found. 131 * Returns the WebappDataStorage object for webappId, or null if one cannot be found.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 279 }
282 } 280 }
283 } else { 281 } else {
284 if (webapps.contains(idToInitialize) 282 if (webapps.contains(idToInitialize)
285 && (replaceExisting || !mStorages.containsKey(idToInitialize ))) { 283 && (replaceExisting || !mStorages.containsKey(idToInitialize ))) {
286 mStorages.put(idToInitialize, WebappDataStorage.open(idToInitial ize)); 284 mStorages.put(idToInitialize, WebappDataStorage.open(idToInitial ize));
287 } 285 }
288 } 286 }
289 } 287 }
290 } 288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698