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

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: syncing 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
« no previous file with comments | « net/disk_cache/simple/simple_synchronous_entry.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d3091d1be6446b6e85996438dee2076e893d9607..84e0e669bfe58b2aefc932e2a1fc6c4825bec865 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;
return headers_size + data_offset;
@@ -212,6 +216,14 @@ bool SimpleSynchronousEntry::OpenOrCreateFiles(bool create) {
return true;
}
+int64 SimpleSynchronousEntry::GetFileSize() const {
+ 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))
« no previous file with comments | « net/disk_cache/simple/simple_synchronous_entry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698