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++) { |