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

Unified Diff: net/disk_cache/block_files.cc

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 side-by-side diff with in-line comments
Download patch
Index: net/disk_cache/block_files.cc
===================================================================
--- net/disk_cache/block_files.cc (revision 208788)
+++ net/disk_cache/block_files.cc (working copy)
@@ -177,7 +177,7 @@
}
}
-bool BlockHeader::NeedToGrowBlockFile(int block_count) {
+bool BlockHeader::NeedToGrowBlockFile(int block_count) const {
bool have_space = false;
int empty_blocks = 0;
for (int i = 0; i < kMaxNumBlocks; i++) {
@@ -195,6 +195,18 @@
return !have_space;
}
+bool BlockHeader::CanAllocate(int block_count) const {
+ bool have_space = false;
+ int empty_blocks = 0;
+ for (int i = 0; i < kMaxNumBlocks; i++) {
+ empty_blocks += header_->empty[i] * (i + 1);
+ if (i >= block_count - 1 && header_->empty[i])
gavinp 2013/06/27 07:06:18 Nit: I'd find this more readable with () around bl
+ have_space = true;
+ }
+
+ return have_space;
+}
+
int BlockHeader::EmptyBlocks() const {
int empty_blocks = 0;
for (int i = 0; i < disk_cache::kMaxNumBlocks; i++) {

Powered by Google App Engine
This is Rietveld 408576698