Chromium Code Reviews| 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..a881de055283a026dc5d1416c1b6fba32428173b 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; |
|
pasko
2013/09/13 19:09:21
I would prefer to leave stream 2 with the "_2" suf
clamy
2013/09/16 15:01:17
File index is being used as an offset in an array
pasko
2013/09/17 11:29:01
Agreed.
|
| +} |
| + |
| +int GetMaximumDataOffset(int file_index, const int data_size[]) { |
|
pasko
2013/09/13 19:09:21
Naming is fun. This name suggests (at least to me)
clamy
2013/09/16 15:01:17
Done.
|
| + if (file_index == 0) |
| + return data_size[0] + data_size[1] + sizeof(SimpleFileEOF); |
| + 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 |