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

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

Issue 2927723003: [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 // Guarantee that last used time != WebappDataStorage.LAST_USED_ INVALID. Must be 120 // Update the last used time in order to prevent
121 // run on the main thread as SharedPreferences.Editor.apply() is called. 121 // {@link WebappRegistry@unregisterOldWebapps()} from deleting t he
122 // WebappDataStorage. Must be run on the main thread as
123 // SharedPreferences.Editor.apply() is called.
122 mStorages.put(webappId, storage); 124 mStorages.put(webappId, storage);
123 mPreferences.edit().putStringSet(KEY_WEBAPP_SET, mStorages.keySe t()).apply(); 125 mPreferences.edit().putStringSet(KEY_WEBAPP_SET, mStorages.keySe t()).apply();
124 storage.updateLastUsedTime(); 126 storage.updateLastUsedTime();
125 if (callback != null) callback.onWebappDataStorageRetrieved(stor age); 127 if (callback != null) callback.onWebappDataStorageRetrieved(stor age);
126 } 128 }
127 }.execute(); 129 }.execute();
128 } 130 }
129 131
130 /** 132 /**
131 * Returns the WebappDataStorage object for webappId, or null if one cannot be found. 133 * 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
279 } 281 }
280 } 282 }
281 } else { 283 } else {
282 if (webapps.contains(idToInitialize) 284 if (webapps.contains(idToInitialize)
283 && (replaceExisting || !mStorages.containsKey(idToInitialize ))) { 285 && (replaceExisting || !mStorages.containsKey(idToInitialize ))) {
284 mStorages.put(idToInitialize, WebappDataStorage.open(idToInitial ize)); 286 mStorages.put(idToInitialize, WebappDataStorage.open(idToInitial ize));
285 } 287 }
286 } 288 }
287 } 289 }
288 } 290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698