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

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, 5 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.
gavinp 2013/08/05 17:06:15 Can we expand on this comment a bit? I'm still a b
rvargas (doing something else) 2013/08/05 19:50:45 Expended the comment. I can think of handles/repre
gavinp 2013/08/06 01:11:02 None of "handles/represents/encapsulates" are grea
rvargas (doing something else) 2013/08/08 02:50:01 "dedicated files" is a basic concept of this cache
gavinp 2013/08/08 03:04:46 If I understood what this class did, I would be ha
Randy Smith (Not in Mondays) 2013/08/09 19:11:49 At risk of saying something completely wrong (whic
rvargas (doing something else) 2013/08/09 19:53:41 Thanks. I'm more than happy happy to use that desc
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 void Init(const BlockFilesBitmaps& bitmaps);
28 // files should be created or just open.
29 bool Init(bool create_files);
30 24
31 // Creates a new entry on a block file. block_type indicates the size of block 25 // 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 26 // 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. 27 // 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); 28 bool CreateBlock(FileType block_type, int block_count, Addr* block_address);
35 29
36 // Removes an entry from the block files. If deep is true, the storage is zero 30 // Removes an entry from the block files.
37 // filled; otherwise the entry is removed but the data is not altered (must be 31 void DeleteBlock(Addr address);
38 // already zeroed).
39 void DeleteBlock(Addr address, bool deep);
40 32
41 // Close all the files and set the internal state to be initializad again. The 33 // Releases the internal bitmaps. The cache is being purged.
42 // cache is being purged. 34 void Clear();
43 void CloseFiles();
44 35
45 // Sends UMA stats. 36 // Sends UMA stats.
46 void ReportStats(); 37 void ReportStats();
47 38
48 // Returns true if the blocks pointed by a given address are currently used. 39 // Returns true if the blocks pointed by a given address are currently used.
49 // This method is only intended for debugging. 40 // This method is only intended for debugging.
50 bool IsValid(Addr address); 41 bool IsValid(Addr address);
51 42
52 private: 43 private:
53 // Returns the file that stores a given address. 44 // Returns the header number that stores a given address.
54 MappedFile* GetFile(Addr address); 45 int GetHeaderNumber(Addr address);
55 46
56 // Attemp to grow this file. Fails if the file cannot be extended anymore. 47 // Returns the appropriate header to use for a new block.
57 bool GrowBlockFile(MappedFile* file, BlockFileHeader* header); 48 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 49
65 // Retrieves stats for the given file index. 50 // Retrieves stats for the given file index.
66 void GetFileStats(int index, int* used_count, int* load); 51 void GetFileStats(int index, int* used_count, int* load);
67 52
68 bool init_; 53 BlockFilesBitmaps bitmaps_;
69 54
70 DISALLOW_COPY_AND_ASSIGN(BlockFiles); 55 DISALLOW_COPY_AND_ASSIGN(BlockBitmaps);
71 }; 56 };
72 57
73 } // namespace disk_cache 58 } // namespace disk_cache
74 59
75 #endif // NET_DISK_CACHE_BLOCK_FILES_H_ 60 #endif // NET_DISK_CACHE_V3_BLOCK_BITMAPS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698