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

Unified Diff: net/disk_cache/simple/simple_synchronous_entry.cc

Issue 13913010: Add Cache size to the Simple Index. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/simple/simple_synchronous_entry.cc
diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc
index cd88df931a9fdeb3438f7951b81125a1728817c4..4dcb8c2f4ced91ac3b6dfc7642e87663fbe6e6e9 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.cc
+++ b/net/disk_cache/simple/simple_synchronous_entry.cc
@@ -50,6 +50,10 @@ int32 DataSizeFromKeyAndFileSize(size_t key_size, int64 file_size) {
return data_size;
}
+int64 FileSizeFromKeyAndDataSize(size_t key_size, int32 data_size) {
+ return data_size + key_size + sizeof(disk_cache::SimpleFileHeader);
+}
+
int64 FileOffsetFromDataOffset(size_t key_size, int data_offset) {
const int64 headers_size = sizeof(disk_cache::SimpleFileHeader) +
key_size;
@@ -213,6 +217,14 @@ bool SimpleSynchronousEntry::OpenOrCreateFiles(bool create) {
return true;
}
+int64 SimpleSynchronousEntry::GetFileSize() const {
gavinp 2013/04/10 10:33:23 Ordering: methods in a .cc file should be in the s
+ int64 file_size = 0;
+ for (int i = 0; i < kSimpleEntryFileCount; ++i) {
+ file_size += FileSizeFromKeyAndDataSize(key_.size(), data_size_[i]);
+ }
+ return file_size;
+}
+
bool SimpleSynchronousEntry::InitializeForOpen() {
DCHECK(!initialized_);
if (!OpenOrCreateFiles(false))

Powered by Google App Engine
This is Rietveld 408576698