Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / net / disk_cache / blockfile / block_bitmaps_v3.h
blob40eefb14a74f2e4f3eb9d4f7ce6bf25b2ef70340
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.
5 // See net/disk_cache/disk_cache.h for the public interface.
7 #ifndef NET_DISK_CACHE_BLOCKFILE_BLOCK_BITMAPS_V3_H_
8 #define NET_DISK_CACHE_BLOCKFILE_BLOCK_BITMAPS_V3_H_
10 #include "base/files/file_path.h"
11 #include "net/base/net_export.h"
12 #include "net/disk_cache/blockfile/addr.h"
13 #include "net/disk_cache/blockfile/block_files.h"
15 namespace disk_cache {
17 class BackendImplV3;
19 // This class is the interface in the v3 disk cache to the set of files holding
20 // cached data that is small enough to not be efficiently stored in a dedicated
21 // file (i.e. < kMaxBlockSize). It is primarily used to allocate and free
22 // regions in those files used to store data.
23 class NET_EXPORT_PRIVATE BlockBitmaps {
24 public:
25 BlockBitmaps();
26 ~BlockBitmaps();
28 void Init(const BlockFilesBitmaps& bitmaps);
30 // Creates a new entry on a block file. block_type indicates the size of block
31 // to be used (as defined on cache_addr.h), block_count is the number of
32 // blocks to allocate, and block_address is the address of the new entry.
33 bool CreateBlock(FileType block_type, int block_count, Addr* block_address);
35 // Removes an entry from the block files.
36 void DeleteBlock(Addr address);
38 // Releases the internal bitmaps. The cache is being purged.
39 void Clear();
41 // Sends UMA stats.
42 void ReportStats();
44 // Returns true if the blocks pointed by a given address are currently used.
45 // This method is only intended for debugging.
46 bool IsValid(Addr address);
48 private:
49 // Returns the header number that stores a given address.
50 int GetHeaderNumber(Addr address);
52 // Returns the appropriate header to use for a new block.
53 int HeaderNumberForNewBlock(FileType block_type, int block_count);
55 // Retrieves stats for the given file index.
56 void GetFileStats(int index, int* used_count, int* load);
58 BlockFilesBitmaps bitmaps_;
60 DISALLOW_COPY_AND_ASSIGN(BlockBitmaps);
63 } // namespace disk_cache
65 #endif // NET_DISK_CACHE_BLOCKFILE_BLOCK_BITMAPS_V3_H_