Java Code Examples for org.chromium.chrome.browser.TabState#parseInfoFromFilename()
The following examples show how to use
org.chromium.chrome.browser.TabState#parseInfoFromFilename() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabPersistentStore.java From delion with Apache License 2.0 | 6 votes |
@Override protected void onPostExecute(CleanUpTabStateDataInfo tabStateInfo) { if (mDestroyed || tabStateInfo.mTabFileNames == null) return; for (String fileName : tabStateInfo.mTabFileNames) { Pair<Integer, Boolean> data = TabState.parseInfoFromFilename(fileName); if (data != null) { TabModel model = mTabModelSelector.getModel(data.second); if (mDeleteAllFiles || (TabModelUtils.getTabById(model, data.first) == null && tabStateInfo.mOtherTabIds.get(data.first) == null)) { // It might be more efficient to use a single task for all files, but // the number of files is expected to be very small. deleteFileAsync(fileName); } } } }
Example 2
Source File: TabPersistentStore.java From delion with Apache License 2.0 | 5 votes |
/** * Upgrades users from an old version of Chrome when the state file was still in the root * directory. */ @WorkerThread private void performLegacyMigration() { File newFolder = getStateDirectory(); File[] newFiles = newFolder.listFiles(); // Attempt migration if we have no tab state file in the new directory. if (newFiles == null || newFiles.length == 0) { File oldFolder = mContext.getFilesDir(); File modelFile = new File(oldFolder, SAVED_STATE_FILE); if (modelFile.exists()) { if (!modelFile.renameTo(new File(newFolder, getStateFileName(mSelectorIndex)))) { Log.e(TAG, "Failed to rename file: " + modelFile); } } File[] files = oldFolder.listFiles(); if (files != null) { for (File file : files) { if (TabState.parseInfoFromFilename(file.getName()) != null) { if (!file.renameTo(new File(newFolder, file.getName()))) { Log.e(TAG, "Failed to rename file: " + file); } } } } } setLegacyFileMigrationPref(); }
Example 3
Source File: IncognitoNotificationService.java From delion with Apache License 2.0 | 5 votes |
/** * @return Whether deleting all the incognito files was successful. */ private boolean deleteIncognitoStateFilesInDirectory(File directory) { File[] allTabStates = directory.listFiles(); if (allTabStates == null) return true; boolean deletionSuccessful = true; for (int i = 0; i < allTabStates.length; i++) { String fileName = allTabStates[i].getName(); Pair<Integer, Boolean> tabInfo = TabState.parseInfoFromFilename(fileName); if (tabInfo == null || !tabInfo.second) continue; deletionSuccessful &= allTabStates[i].delete(); } return deletionSuccessful; }
Example 4
Source File: TabbedModeTabPersistencePolicy.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Upgrades users from an old version of Chrome when the state file was still in the root * directory. */ @WorkerThread private void performLegacyMigration() { Log.w(TAG, "Starting to perform legacy migration."); File newFolder = getOrCreateStateDirectory(); File[] newFiles = newFolder.listFiles(); // Attempt migration if we have no tab state file in the new directory. if (newFiles == null || newFiles.length == 0) { File oldFolder = ContextUtils.getApplicationContext().getFilesDir(); File modelFile = new File(oldFolder, LEGACY_SAVED_STATE_FILE); if (modelFile.exists()) { if (!modelFile.renameTo(new File(newFolder, getStateFileName()))) { Log.e(TAG, "Failed to rename file: " + modelFile); } } File[] files = oldFolder.listFiles(); if (files != null) { for (File file : files) { if (TabState.parseInfoFromFilename(file.getName()) != null) { if (!file.renameTo(new File(newFolder, file.getName()))) { Log.e(TAG, "Failed to rename file: " + file); } } } } } setLegacyFileMigrationPref(); Log.w(TAG, "Finished performing legacy migration."); }
Example 5
Source File: IncognitoNotificationService.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @return Whether deleting all the incognito files was successful. */ private boolean deleteIncognitoStateFilesInDirectory(File directory) { File[] allTabStates = directory.listFiles(); if (allTabStates == null) return true; boolean deletionSuccessful = true; for (int i = 0; i < allTabStates.length; i++) { String fileName = allTabStates[i].getName(); Pair<Integer, Boolean> tabInfo = TabState.parseInfoFromFilename(fileName); if (tabInfo == null || !tabInfo.second) continue; deletionSuccessful &= allTabStates[i].delete(); } return deletionSuccessful; }
Example 6
Source File: CustomTabTabPersistencePolicy.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override protected Void doInBackground(Void... voids) { if (mDestroyed) return null; mTabIdsByMetadataFile = new HashMap<>(); mUnreferencedTabIds = new HashSet<>(); File[] stateFiles = getOrCreateStateDirectory().listFiles(); if (stateFiles == null) return null; Set<Integer> allTabIds = new HashSet<>(); Set<Integer> allReferencedTabIds = new HashSet<>(); List<File> metadataFiles = new ArrayList<>(); for (File file : stateFiles) { if (TabPersistentStore.isStateFile(file.getName())) { metadataFiles.add(file); SparseBooleanArray tabIds = new SparseBooleanArray(); mTabIdsByMetadataFile.put(file, tabIds); getTabsFromStateFile(tabIds, file); for (int i = 0; i < tabIds.size(); i++) { allReferencedTabIds.add(tabIds.keyAt(i)); } continue; } Pair<Integer, Boolean> tabInfo = TabState.parseInfoFromFilename(file.getName()); if (tabInfo == null) continue; allTabIds.add(tabInfo.first); } mUnreferencedTabIds.addAll(allTabIds); mUnreferencedTabIds.removeAll(allReferencedTabIds); mDeletableMetadataFiles = getMetadataFilesForDeletion( System.currentTimeMillis(), metadataFiles); return null; }
Example 7
Source File: TabbedModeTabPersistencePolicy.java From 365browser with Apache License 2.0 | 5 votes |
/** * Upgrades users from an old version of Chrome when the state file was still in the root * directory. */ @WorkerThread private void performLegacyMigration() { Log.w(TAG, "Starting to perform legacy migration."); File newFolder = getOrCreateStateDirectory(); File[] newFiles = newFolder.listFiles(); // Attempt migration if we have no tab state file in the new directory. if (newFiles == null || newFiles.length == 0) { File oldFolder = ContextUtils.getApplicationContext().getFilesDir(); File modelFile = new File(oldFolder, LEGACY_SAVED_STATE_FILE); if (modelFile.exists()) { if (!modelFile.renameTo(new File(newFolder, getStateFileName()))) { Log.e(TAG, "Failed to rename file: " + modelFile); } } File[] files = oldFolder.listFiles(); if (files != null) { for (File file : files) { if (TabState.parseInfoFromFilename(file.getName()) != null) { if (!file.renameTo(new File(newFolder, file.getName()))) { Log.e(TAG, "Failed to rename file: " + file); } } } } } setLegacyFileMigrationPref(); Log.w(TAG, "Finished performing legacy migration."); }
Example 8
Source File: IncognitoNotificationService.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return Whether deleting all the incognito files was successful. */ private boolean deleteIncognitoStateFilesInDirectory(File directory) { File[] allTabStates = directory.listFiles(); if (allTabStates == null) return true; boolean deletionSuccessful = true; for (int i = 0; i < allTabStates.length; i++) { String fileName = allTabStates[i].getName(); Pair<Integer, Boolean> tabInfo = TabState.parseInfoFromFilename(fileName); if (tabInfo == null || !tabInfo.second) continue; deletionSuccessful &= allTabStates[i].delete(); } return deletionSuccessful; }
Example 9
Source File: CustomTabTabPersistencePolicy.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected Void doInBackground(Void... voids) { if (mDestroyed) return null; mTabIdsByMetadataFile = new HashMap<>(); mUnreferencedTabIds = new HashSet<>(); File[] stateFiles = getOrCreateStateDirectory().listFiles(); if (stateFiles == null) return null; Set<Integer> allTabIds = new HashSet<>(); Set<Integer> allReferencedTabIds = new HashSet<>(); List<File> metadataFiles = new ArrayList<>(); for (File file : stateFiles) { if (TabPersistentStore.isStateFile(file.getName())) { metadataFiles.add(file); SparseBooleanArray tabIds = new SparseBooleanArray(); mTabIdsByMetadataFile.put(file, tabIds); getTabsFromStateFile(tabIds, file); for (int i = 0; i < tabIds.size(); i++) { allReferencedTabIds.add(tabIds.keyAt(i)); } continue; } Pair<Integer, Boolean> tabInfo = TabState.parseInfoFromFilename(file.getName()); if (tabInfo == null) continue; allTabIds.add(tabInfo.first); } mUnreferencedTabIds.addAll(allTabIds); mUnreferencedTabIds.removeAll(allReferencedTabIds); mDeletableMetadataFiles = getMetadataFilesForDeletion( System.currentTimeMillis(), metadataFiles); return null; }