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

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, 6 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
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 // This class handles the set of block-files open by the disk cache.
22 class NET_EXPORT_PRIVATE BlockFiles { 18 class NET_EXPORT_PRIVATE BlockBitmaps {
23 public: 19 public:
24 explicit BlockFiles(const base::FilePath& path); 20 BlockBitmaps();
25 ~BlockFiles(); 21 ~BlockBitmaps();
26 22
27 // Performs the object initialization. create_files indicates if the backing 23 // Performs the object initialization.
gavinp 2013/06/27 07:06:18 Nit: we can lose this comment.
28 // files should be created or just open. 24 void Init(const BlockFilesBitmaps& bitmaps);
29 bool Init(bool create_files);
30 25
31 // Creates a new entry on a block file. block_type indicates the size of block 26 // 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 27 // 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. 28 // 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); 29 bool CreateBlock(FileType block_type, int block_count, Addr* block_address);
35 30
36 // Removes an entry from the block files. If deep is true, the storage is zero 31 // Removes an entry from the block files.
37 // filled; otherwise the entry is removed but the data is not altered (must be 32 void DeleteBlock(Addr address);
38 // already zeroed).
39 void DeleteBlock(Addr address, bool deep);
40 33
41 // Close all the files and set the internal state to be initializad again. The 34 // Releases the internal bitmaps. The cache is being purged.
42 // cache is being purged. 35 void Clear();
43 void CloseFiles();
44 36
45 // Sends UMA stats. 37 // Sends UMA stats.
46 void ReportStats(); 38 void ReportStats();
47 39
48 // Returns true if the blocks pointed by a given address are currently used. 40 // Returns true if the blocks pointed by a given address are currently used.
49 // This method is only intended for debugging. 41 // This method is only intended for debugging.
50 bool IsValid(Addr address); 42 bool IsValid(Addr address);
51 43
52 private: 44 private:
53 // Returns the file that stores a given address. 45 // Returns the header number that stores a given address.
54 MappedFile* GetFile(Addr address); 46 int GetHeaderNumber(Addr address);
55 47
56 // Attemp to grow this file. Fails if the file cannot be extended anymore. 48 // Returns the appropriate header to use for a new block.
57 bool GrowBlockFile(MappedFile* file, BlockFileHeader* header); 49 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 50
65 // Retrieves stats for the given file index. 51 // Retrieves stats for the given file index.
66 void GetFileStats(int index, int* used_count, int* load); 52 void GetFileStats(int index, int* used_count, int* load);
67 53
68 bool init_; 54 BlockFilesBitmaps bitmaps_;
69 55
70 DISALLOW_COPY_AND_ASSIGN(BlockFiles); 56 DISALLOW_COPY_AND_ASSIGN(BlockBitmaps);
71 }; 57 };
72 58
73 } // namespace disk_cache 59 } // namespace disk_cache
74 60
75 #endif // NET_DISK_CACHE_BLOCK_FILES_H_ 61 #endif // NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698