// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_VERSION_UPGRADE_H_ #define NET_DISK_CACHE_SIMPLE_SIMPLE_VERSION_UPGRADE_H_ // Defines functionality to upgrade the file structure of the Simple Cache // Backend on disk. Assumes no backend operations are running simultaneously. // Hence must be run at cache initialization step. #include <stdint.h> #include "net/base/cache_type.h" #include "net/base/net_export.h" namespace base { class FilePath; } namespace disk_cache { class BackendFileOperations; // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. enum class SimpleCacheConsistencyResult { … }; // Performs all necessary disk IO to upgrade the cache structure if it is // needed. // // Returns true iff no errors were found during consistency checks and all // necessary transitions succeeded. If this function fails, there is nothing // left to do other than dropping the whole cache directory. NET_EXPORT_PRIVATE SimpleCacheConsistencyResult UpgradeSimpleCacheOnDisk(BackendFileOperations* file_operations, const base::FilePath& path); // Check if the cache structure at the given path is empty except for index // files. If so, then delete the index files. Returns true if any files // were deleted. NET_EXPORT_PRIVATE bool DeleteIndexFilesIfCacheIsEmpty( const base::FilePath& path); struct NET_EXPORT_PRIVATE FakeIndexData { … }; // Exposed for testing. NET_EXPORT_PRIVATE bool UpgradeIndexV5V6(BackendFileOperations* file_operations, const base::FilePath& cache_directory); } // namespace disk_cache #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_VERSION_UPGRADE_H_