Index: net/disk_cache/v3/block_bitmaps.h |
=================================================================== |
--- net/disk_cache/v3/block_bitmaps.h (revision 222596) |
+++ net/disk_cache/v3/block_bitmaps.h (working copy) |
@@ -4,43 +4,39 @@ |
// See net/disk_cache/disk_cache.h for the public interface. |
-#ifndef NET_DISK_CACHE_BLOCK_FILES_H_ |
-#define NET_DISK_CACHE_BLOCK_FILES_H_ |
+#ifndef NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_ |
+#define NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_ |
-#include <vector> |
- |
#include "base/files/file_path.h" |
-#include "base/gtest_prod_util.h" |
-#include "base/memory/scoped_ptr.h" |
#include "net/base/net_export.h" |
#include "net/disk_cache/addr.h" |
-#include "net/disk_cache/mapped_file.h" |
+#include "net/disk_cache/block_files.h" |
namespace disk_cache { |
-// This class handles the set of block-files open by the disk cache. |
-class NET_EXPORT_PRIVATE BlockFiles { |
+class BackendImplV3; |
+ |
+// This class is the interface in the v3 disk cache to the set of files holding |
+// cached data that is small enough to not be efficiently stored in a dedicated |
+// file (i.e. < kMaxBlockSize). It is primarily used to allocate and free |
+// regions in those files used to store data. |
+class NET_EXPORT_PRIVATE BlockBitmaps { |
public: |
- explicit BlockFiles(const base::FilePath& path); |
- ~BlockFiles(); |
+ BlockBitmaps(); |
+ ~BlockBitmaps(); |
- // Performs the object initialization. create_files indicates if the backing |
- // files should be created or just open. |
- bool Init(bool create_files); |
+ void Init(const BlockFilesBitmaps& bitmaps); |
// Creates a new entry on a block file. block_type indicates the size of block |
// to be used (as defined on cache_addr.h), block_count is the number of |
// blocks to allocate, and block_address is the address of the new entry. |
bool CreateBlock(FileType block_type, int block_count, Addr* block_address); |
- // Removes an entry from the block files. If deep is true, the storage is zero |
- // filled; otherwise the entry is removed but the data is not altered (must be |
- // already zeroed). |
- void DeleteBlock(Addr address, bool deep); |
+ // Removes an entry from the block files. |
+ void DeleteBlock(Addr address); |
- // Close all the files and set the internal state to be initializad again. The |
- // cache is being purged. |
- void CloseFiles(); |
+ // Releases the internal bitmaps. The cache is being purged. |
+ void Clear(); |
// Sends UMA stats. |
void ReportStats(); |
@@ -50,26 +46,20 @@ |
bool IsValid(Addr address); |
private: |
- // Returns the file that stores a given address. |
- MappedFile* GetFile(Addr address); |
+ // Returns the header number that stores a given address. |
+ int GetHeaderNumber(Addr address); |
- // Attemp to grow this file. Fails if the file cannot be extended anymore. |
- bool GrowBlockFile(MappedFile* file, BlockFileHeader* header); |
+ // Returns the appropriate header to use for a new block. |
+ int HeaderNumberForNewBlock(FileType block_type, int block_count); |
- // Returns the appropriate file to use for a new block. |
- MappedFile* FileForNewBlock(FileType block_type, int block_count); |
- |
- // Restores the header of a potentially inconsistent file. |
- bool FixBlockFileHeader(MappedFile* file); |
- |
// Retrieves stats for the given file index. |
void GetFileStats(int index, int* used_count, int* load); |
- bool init_; |
+ BlockFilesBitmaps bitmaps_; |
- DISALLOW_COPY_AND_ASSIGN(BlockFiles); |
+ DISALLOW_COPY_AND_ASSIGN(BlockBitmaps); |
}; |
} // namespace disk_cache |
-#endif // NET_DISK_CACHE_BLOCK_FILES_H_ |
+#endif // NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_ |