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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabTabPersistencePolicy.java

Issue 2520103002: Delete tab state files when the user explicitly closes a CCT. (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.customtabs; 5 package org.chromium.chrome.browser.customtabs;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.os.AsyncTask; 8 import android.os.AsyncTask;
9 import android.os.StrictMode; 9 import android.os.StrictMode;
10 import android.util.Pair; 10 import android.util.Pair;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 @Override 198 @Override
199 public void notifyStateLoaded(int tabCountAtStartup) { 199 public void notifyStateLoaded(int tabCountAtStartup) {
200 } 200 }
201 201
202 @Override 202 @Override
203 public void destroy() { 203 public void destroy() {
204 mDestroyed = true; 204 mDestroyed = true;
205 } 205 }
206 206
207 /** 207 /**
208 * Triggers an async deletion of the tab state metadata file.
209 */
210 public void deleteMetadataStateFileAsync() {
211 AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
212 @Override
213 public void run() {
214 File stateDir = getOrCreateStateDirectory();
215 File metadataFile = new File(stateDir, getStateFileName());
216 if (metadataFile.exists() && !metadataFile.delete()) {
217 Log.e(TAG, "Failed to delete file: " + metadataFile);
218 }
219 }
220 });
221 }
222
223 /**
208 * Given a list of metadata files, determine which are applicable for deleti on based on the 224 * Given a list of metadata files, determine which are applicable for deleti on based on the
209 * deletion strategy of Custom Tabs. 225 * deletion strategy of Custom Tabs.
210 * 226 *
211 * @param currentTimeMillis The current time in milliseconds 227 * @param currentTimeMillis The current time in milliseconds
212 * ({@link System#currentTimeMillis()}. 228 * ({@link System#currentTimeMillis()}.
213 * @param allMetadataFiles The complete list of all metadata files to check. 229 * @param allMetadataFiles The complete list of all metadata files to check.
214 * @return The list of metadata files that are applicable for deletion. 230 * @return The list of metadata files that are applicable for deletion.
215 */ 231 */
216 protected static List<File> getMetadataFilesForDeletion( 232 protected static List<File> getMetadataFilesForDeletion(
217 long currentTimeMillis, List<File> allMetadataFiles) { 233 long currentTimeMillis, List<File> allMetadataFiles) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 new BufferedInputStream(new FileInputStream(metadataFile ))); 403 new BufferedInputStream(new FileInputStream(metadataFile )));
388 TabPersistentStore.readSavedStateFile(stream, null, tabIds, fals e); 404 TabPersistentStore.readSavedStateFile(stream, null, tabIds, fals e);
389 } catch (Exception e) { 405 } catch (Exception e) {
390 Log.e(TAG, "Unable to read state for " + metadataFile.getName() + ": " + e); 406 Log.e(TAG, "Unable to read state for " + metadataFile.getName() + ": " + e);
391 } finally { 407 } finally {
392 StreamUtil.closeQuietly(stream); 408 StreamUtil.closeQuietly(stream);
393 } 409 }
394 } 410 }
395 } 411 }
396 } 412 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java ('k') | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698