Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(963)

Side by Side Diff: net/disk_cache/v3/block_bitmaps.h

Issue 17816008: Disk cache: Introduce BlockBitmaps for V3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/disk_format_base.h ('k') | net/disk_cache/v3/block_bitmaps.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See net/disk_cache/disk_cache.h for the public interface. 5 // See net/disk_cache/disk_cache.h for the public interface.
6 6
7 #ifndef NET_DISK_CACHE_BLOCK_FILES_H_ 7 #ifndef NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_
8 #define NET_DISK_CACHE_BLOCK_FILES_H_ 8 #define NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_
9
10 #include <vector>
11 9
12 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
16 #include "net/disk_cache/addr.h" 12 #include "net/disk_cache/addr.h"
17 #include "net/disk_cache/mapped_file.h" 13 #include "net/disk_cache/block_files.h"
18 14
19 namespace disk_cache { 15 namespace disk_cache {
20 16
21 // This class handles the set of block-files open by the disk cache. 17 class BackendImplV3;
22 class NET_EXPORT_PRIVATE BlockFiles { 18
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 {
23 public: 24 public:
24 explicit BlockFiles(const base::FilePath& path); 25 BlockBitmaps();
25 ~BlockFiles(); 26 ~BlockBitmaps();
26 27
27 // Performs the object initialization. create_files indicates if the backing 28 void Init(const BlockFilesBitmaps& bitmaps);
28 // files should be created or just open.
29 bool Init(bool create_files);
30 29
31 // Creates a new entry on a block file. block_type indicates the size of block 30 // 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 31 // 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. 32 // 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); 33 bool CreateBlock(FileType block_type, int block_count, Addr* block_address);
35 34
36 // Removes an entry from the block files. If deep is true, the storage is zero 35 // Removes an entry from the block files.
37 // filled; otherwise the entry is removed but the data is not altered (must be 36 void DeleteBlock(Addr address);
38 // already zeroed).
39 void DeleteBlock(Addr address, bool deep);
40 37
41 // Close all the files and set the internal state to be initializad again. The 38 // Releases the internal bitmaps. The cache is being purged.
42 // cache is being purged. 39 void Clear();
43 void CloseFiles();
44 40
45 // Sends UMA stats. 41 // Sends UMA stats.
46 void ReportStats(); 42 void ReportStats();
47 43
48 // Returns true if the blocks pointed by a given address are currently used. 44 // Returns true if the blocks pointed by a given address are currently used.
49 // This method is only intended for debugging. 45 // This method is only intended for debugging.
50 bool IsValid(Addr address); 46 bool IsValid(Addr address);
51 47
52 private: 48 private:
53 // Returns the file that stores a given address. 49 // Returns the header number that stores a given address.
54 MappedFile* GetFile(Addr address); 50 int GetHeaderNumber(Addr address);
55 51
56 // Attemp to grow this file. Fails if the file cannot be extended anymore. 52 // Returns the appropriate header to use for a new block.
57 bool GrowBlockFile(MappedFile* file, BlockFileHeader* header); 53 int HeaderNumberForNewBlock(FileType block_type, int block_count);
58
59 // Returns the appropriate file to use for a new block.
60 MappedFile* FileForNewBlock(FileType block_type, int block_count);
61
62 // Restores the header of a potentially inconsistent file.
63 bool FixBlockFileHeader(MappedFile* file);
64 54
65 // Retrieves stats for the given file index. 55 // Retrieves stats for the given file index.
66 void GetFileStats(int index, int* used_count, int* load); 56 void GetFileStats(int index, int* used_count, int* load);
67 57
68 bool init_; 58 BlockFilesBitmaps bitmaps_;
69 59
70 DISALLOW_COPY_AND_ASSIGN(BlockFiles); 60 DISALLOW_COPY_AND_ASSIGN(BlockBitmaps);
71 }; 61 };
72 62
73 } // namespace disk_cache 63 } // namespace disk_cache
74 64
75 #endif // NET_DISK_CACHE_BLOCK_FILES_H_ 65 #endif // NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_
OLDNEW
« no previous file with comments | « net/disk_cache/disk_format_base.h ('k') | net/disk_cache/v3/block_bitmaps.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698