| Index: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistencePolicy.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistencePolicy.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistencePolicy.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..aedf958d3533b0eb9b0578be9f15c14d45436813
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabPersistencePolicy.java
|
| @@ -0,0 +1,99 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.chrome.browser.tabmodel;
|
| +
|
| +import org.chromium.base.Callback;
|
| +import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
|
| +
|
| +import java.io.File;
|
| +import java.util.List;
|
| +import java.util.concurrent.Executor;
|
| +
|
| +import javax.annotation.Nullable;
|
| +
|
| +/**
|
| + * Policy that handles the Activity specific behaviors regarding the persistence of tab data.
|
| + */
|
| +public interface TabPersistencePolicy {
|
| +
|
| + /**
|
| + * The prefix of the name of the file where the state is saved. {@link #getStateFileName()}
|
| + * and {@link #getStateToBeMergedFileName()} must begin with this prefix.
|
| + */
|
| + String SAVED_STATE_FILE_PREFIX = "tab_state";
|
| +
|
| + /**
|
| + * @return File representing the directory that is used to store Tab state
|
| + * information.
|
| + */
|
| + File getOrCreateStateDirectory();
|
| +
|
| + /**
|
| + * @return The filename of the primary state file containing information about the tabs to be
|
| + * loaded.
|
| + */
|
| + String getStateFileName();
|
| +
|
| + /**
|
| + * @return The filename of the state that is to be merged.
|
| + */
|
| + @Nullable
|
| + String getStateToBeMergedFileName();
|
| +
|
| + /**
|
| + * Performs any necessary migration required before accessing the tab information.
|
| + *
|
| + * @param executor The executor that any asynchronous tasks should be run on.
|
| + * @return Whether any migration is necessary.
|
| + */
|
| + boolean performMigration(Executor executor);
|
| +
|
| + /**
|
| + * Waits for the task that migrates all state files to their new location to
|
| + * finish.
|
| + */
|
| + void waitForMigrationToFinish();
|
| +
|
| + /**
|
| + * @return Whether a merge is currently in progress.
|
| + */
|
| + // TODO(tedchoc): Merging is currently very tabbed mode specific. Investigate moving more
|
| + // of the merging logic into this class and out of the main persistence store.
|
| + boolean isMergeInProgress();
|
| +
|
| + /**
|
| + * Marks whether a merge operation has begun or ended.
|
| + * @param isStarted Whether a merge has been started.
|
| + */
|
| + void setMergeInProgress(boolean isStarted);
|
| +
|
| + /**
|
| + * Cancels any pending cleanups in progress.
|
| + */
|
| + void cancelCleanupInProgress();
|
| +
|
| + /**
|
| + * Trigger a clean up for any unused files (both individual state files for tabs as well as
|
| + * state files for the models).
|
| + *
|
| + * @param filesToDelete Callback that is triggered with the filenames to delete. These files
|
| + * need to reside in {@link #getOrCreateStateDirectory()}.
|
| + */
|
| + // TODO(tedchoc): Clean up this API. This does a mixture of file deletion as well as collecting
|
| + // files to be deleted. It should either handle all deletions internally or not
|
| + // do anything but collect files to be deleted.
|
| + void cleanupUnusedFiles(Callback<List<String>> filesToDelete);
|
| +
|
| + /**
|
| + * Sets the {@link TabContentManager} to use.
|
| + * @param cache The {@link TabContentManager} to use.
|
| + */
|
| + void setTabContentManager(TabContentManager cache);
|
| +
|
| + /**
|
| + * Notify that persistent store has been destroyed.
|
| + */
|
| + void destroy();
|
| +}
|
|
|