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

Unified Diff: net/disk_cache/block_files.h

Issue 16843007: Disk cache: Introduce a BlockHeader class. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/disk_cache/block_files.cc » ('j') | net/disk_cache/block_files.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/block_files.h
===================================================================
--- net/disk_cache/block_files.h (revision 205976)
+++ net/disk_cache/block_files.h (working copy)
@@ -22,6 +22,53 @@
namespace disk_cache {
+// An instance of this class represents the header of a block file in memory.
+// Note that this class doesn't perform any file operation.
+class BlockHeader {
gavinp 2013/06/14 15:37:02 Is this class ever referenced in any translation u
rvargas (doing something else) 2013/06/14 18:32:07 Sure, https://codereview.chromium.org/15203004/dif
rvargas (doing something else) 2013/06/18 18:12:23 I'm sorry, this was not completely accurate... the
+ public:
+ BlockHeader();
+ explicit BlockHeader(BlockFileHeader* header);
+ explicit BlockHeader(MappedFile* file);
+ BlockHeader(const BlockHeader& other);
+ ~BlockHeader();
+
+ // Creates a new entry on the allocation map, updating the apropriate
+ // counters. |target| is the type of block to use (number of empty blocks),
+ // and |size| is the actual number of blocks to use.
+ bool CreateMapBlock(int target, int size, int* index);
+
+ // Deletes the block pointed by |index|.
+ void DeleteMapBlock(int index, int block_size);
+
+ // Returns true if the specified block is used.
+ bool UsedMapBlock(int index, int size);
+
+ // Restores the "empty counters" and allocation hints.
+ void FixAllocationCounters();
+
+ // Returns true if the current block file should not be used as-is to store
+ // more records. |block_count| is the number of blocks to allocate.
+ bool NeedToGrowBlockFile(int block_count);
+
+ // Returns the number of empty blocks for this file.
+ int EmptyBlocks() const;
+
+ // Returns true if the counters look OK.
+ bool ValidateCounters() const;
+
+ // Returns the size of the wrapped structure (BlockFileHeader).
+ int Size() const;
+
+ BlockFileHeader* operator->() { return header_; }
+ void operator=(const BlockHeader& other) { header_ = other.header_; }
+ BlockFileHeader* Get() { return header_; }
+
+ private:
+ BlockFileHeader* header_;
gavinp 2013/06/14 15:37:02 #include "net/disk_cache/disk_format_base.h"
rvargas (doing something else) 2013/06/14 18:32:07 Done.
+};
+
+typedef std::vector<BlockHeader> BlockFilesBitmaps;
+
// This class handles the set of block-files open by the disk cache.
class NET_EXPORT_PRIVATE BlockFiles {
public:
« no previous file with comments | « no previous file | net/disk_cache/block_files.cc » ('j') | net/disk_cache/block_files.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698