| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // See net/disk_cache/disk_cache.h for the public interface. | |
| 6 | |
| 7 #ifndef NET_DISK_CACHE_BLOCKFILE_BLOCK_BITMAPS_V3_H_ | |
| 8 #define NET_DISK_CACHE_BLOCKFILE_BLOCK_BITMAPS_V3_H_ | |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "net/base/net_export.h" | |
| 13 #include "net/disk_cache/blockfile/addr.h" | |
| 14 #include "net/disk_cache/blockfile/block_files.h" | |
| 15 | |
| 16 namespace disk_cache { | |
| 17 | |
| 18 class BackendImplV3; | |
| 19 | |
| 20 // This class is the interface in the v3 disk cache to the set of files holding | |
| 21 // cached data that is small enough to not be efficiently stored in a dedicated | |
| 22 // file (i.e. < kMaxBlockSize). It is primarily used to allocate and free | |
| 23 // regions in those files used to store data. | |
| 24 class NET_EXPORT_PRIVATE BlockBitmaps { | |
| 25 public: | |
| 26 BlockBitmaps(); | |
| 27 ~BlockBitmaps(); | |
| 28 | |
| 29 void Init(const BlockFilesBitmaps& bitmaps); | |
| 30 | |
| 31 // Creates a new entry on a block file. block_type indicates the size of block | |
| 32 // to be used (as defined on cache_addr.h), block_count is the number of | |
| 33 // blocks to allocate, and block_address is the address of the new entry. | |
| 34 bool CreateBlock(FileType block_type, int block_count, Addr* block_address); | |
| 35 | |
| 36 // Removes an entry from the block files. | |
| 37 void DeleteBlock(Addr address); | |
| 38 | |
| 39 // Releases the internal bitmaps. The cache is being purged. | |
| 40 void Clear(); | |
| 41 | |
| 42 // Sends UMA stats. | |
| 43 void ReportStats(); | |
| 44 | |
| 45 // Returns true if the blocks pointed by a given address are currently used. | |
| 46 // This method is only intended for debugging. | |
| 47 bool IsValid(Addr address); | |
| 48 | |
| 49 private: | |
| 50 // Returns the header number that stores a given address. | |
| 51 int GetHeaderNumber(Addr address); | |
| 52 | |
| 53 // Returns the appropriate header to use for a new block. | |
| 54 int HeaderNumberForNewBlock(FileType block_type, int block_count); | |
| 55 | |
| 56 // Retrieves stats for the given file index. | |
| 57 void GetFileStats(int index, int* used_count, int* load); | |
| 58 | |
| 59 BlockFilesBitmaps bitmaps_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(BlockBitmaps); | |
| 62 }; | |
| 63 | |
| 64 } // namespace disk_cache | |
| 65 | |
| 66 #endif // NET_DISK_CACHE_BLOCKFILE_BLOCK_BITMAPS_V3_H_ | |
| OLD | NEW |