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

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

Issue 23983005: SimpleCache: merge the first and second stream in one file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stream 0 size in footer Created 7 years, 3 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
« net/disk_cache/simple/simple_util.h ('K') | « net/disk_cache/simple/simple_util.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_util.cc
diff --git a/net/disk_cache/simple/simple_util.cc b/net/disk_cache/simple/simple_util.cc
index 4a89f9b5eb61c61bf01e08104648a15c7482f24c..23f7ec95d136e805d330993a8d76ace5e9718dfa 100644
--- a/net/disk_cache/simple/simple_util.cc
+++ b/net/disk_cache/simple/simple_util.cc
@@ -98,10 +98,24 @@ int64 GetFileSizeFromKeyAndDataSize(const std::string& key, int32 data_size) {
sizeof(SimpleFileEOF);
}
-int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key,
- int data_offset) {
+int GetFileIndexFromStreamIndex(int stream_index) {
+ return (stream_index == 2) ? 1 : 0;
+}
+
+int GetLastEOFRecordOffset(int file_index, const int data_size[]) {
+ if (file_index == 0)
+ return data_size[0] + data_size[1] + sizeof(SimpleFileEOF);
Deprecated (see juliatuttle) 2013/09/16 20:01:52 This looks like it's vulnerable to an integer over
pasko 2013/09/17 10:06:34 This should be fine. Currently Write operations w
+ return data_size[2];
+}
+
+int64 GetFileOffsetFromDataOffset(const std::string& key,
+ int data_offset,
+ int index,
+ int stream_1_size) {
const int64 headers_size = sizeof(disk_cache::SimpleFileHeader) + key.size();
- return headers_size + data_offset;
+ const int64 additional_offset =
+ index == 0 ? stream_1_size + sizeof(SimpleFileEOF) : 0;
+ return headers_size + data_offset + additional_offset;
}
// TODO(clamy, gavinp): this should go in base
« net/disk_cache/simple/simple_util.h ('K') | « net/disk_cache/simple/simple_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698