| 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_V3_BLOCK_BITMAPS_H_ |
| 8 #define NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_ |
| 9 |
| 10 #include "base/files/file_path.h" |
| 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "net/base/net_export.h" |
| 14 #include "net/disk_cache/addr.h" |
| 15 #include "net/disk_cache/block_files.h" |
| 16 #include "net/disk_cache/mapped_file.h" |
| 17 |
| 18 namespace disk_cache { |
| 19 |
| 20 class BackendImplV3; |
| 21 |
| 22 // This class handles the set of block-files open by the disk cache. |
| 23 class NET_EXPORT_PRIVATE BlockBitmaps { |
| 24 public: |
| 25 explicit BlockBitmaps(BackendImplV3* backend); |
| 26 ~BlockBitmaps(); |
| 27 |
| 28 // Performs the object initialization. |
| 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 number of entry blocks for the given file type. |
| 54 int EmptyBlocksForType(int first_file); |
| 55 |
| 56 // Returns the appropriate header to use for a new block. |
| 57 int HeaderForNewBlock(FileType block_type, int block_count); |
| 58 |
| 59 // Retrieves stats for the given file index. |
| 60 void GetFileStats(int index, int* used_count, int* load); |
| 61 |
| 62 BlockFilesBitmaps bitmaps_; |
| 63 BackendImplV3* backend_; |
| 64 int empty_counts_[kFirstAdditionalBlockFileV3]; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(BlockBitmaps); |
| 67 }; |
| 68 |
| 69 } // namespace disk_cache |
| 70 |
| 71 #endif // NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_ |
| OLD | NEW |