Chromium Code Reviews| Index: net/disk_cache/simple/simple_synchronous_entry.h |
| diff --git a/net/disk_cache/simple/simple_synchronous_entry.h b/net/disk_cache/simple/simple_synchronous_entry.h |
| index f4b5ed81020538c9917f40db4d93a84f7e5d298f..f674ead0d1d01672cb71ffe2d4062eba90c9ac0b 100644 |
| --- a/net/disk_cache/simple/simple_synchronous_entry.h |
| +++ b/net/disk_cache/simple/simple_synchronous_entry.h |
| @@ -11,6 +11,7 @@ |
| #include <vector> |
| #include "base/files/file_path.h" |
| +#include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/platform_file.h" |
| #include "base/time/time.h" |
| @@ -18,6 +19,7 @@ |
| #include "net/disk_cache/simple/simple_entry_format.h" |
| namespace net { |
| +class GrowableIOBuffer; |
| class IOBuffer; |
| } |
| @@ -25,15 +27,33 @@ namespace disk_cache { |
| class SimpleSynchronousEntry; |
| -struct SimpleEntryStat { |
| - SimpleEntryStat(); |
| - SimpleEntryStat(base::Time last_used_p, |
| - base::Time last_modified_p, |
| - const int32 data_size_p[]); |
| +class SimpleEntryStat { |
|
pasko
2013/09/18 16:53:56
Now please add a one-sentence comment describing w
clamy
2013/09/18 17:20:46
Done.
|
| + public: |
| + SimpleEntryStat(base::Time last_used, |
| + base::Time last_modified, |
| + const int32 data_size[]); |
| + |
| + int GetOffsetInFile(const std::string& key, |
| + int offset, |
| + int stream_index) const; |
| + int GetEOFOffsetInFile(const std::string& key, int stream_index) const; |
| + int GetLastEOFOffsetInFile(const std::string& key, int file_index) const; |
| + int GetFileSize(const std::string& key, int file_index) const; |
| + |
| + base::Time last_used() const { return last_used_; } |
| + base::Time last_modified() const { return last_modified_; } |
| + void set_last_used(base::Time last_used) { last_used_ = last_used; } |
| + void set_last_modified(base::Time last_modified) { |
| + last_modified_ = last_modified; |
| + } |
| + |
| + int32 data_size(int i) const { return data_size_[i]; } |
|
pasko
2013/09/18 16:53:56
I would prefer s/i/stream/ or s/i/stream_index/
clamy
2013/09/18 17:20:46
Done.
|
| + void set_data_size(int i, int data_size) { data_size_[i] = data_size; } |
| - base::Time last_used; |
| - base::Time last_modified; |
| - int32 data_size[kSimpleEntryFileCount]; |
| + private: |
| + base::Time last_used_; |
| + base::Time last_modified_; |
| + int32 data_size_[kSimpleEntryStreamCount]; |
| }; |
| struct SimpleEntryCreationResults { |
| @@ -41,7 +61,9 @@ struct SimpleEntryCreationResults { |
| ~SimpleEntryCreationResults(); |
| SimpleSynchronousEntry* sync_entry; |
| + scoped_refptr<net::GrowableIOBuffer> stream_0_data; |
| SimpleEntryStat entry_stat; |
| + uint32 stream_0_crc32; |
| int result; |
| }; |
| @@ -102,21 +124,22 @@ class SimpleSynchronousEntry { |
| void ReadData(const EntryOperationData& in_entry_op, |
| net::IOBuffer* out_buf, |
| uint32* out_crc32, |
| - base::Time* out_last_used, |
| + SimpleEntryStat* out_entry_stat, |
| int* out_result) const; |
| void WriteData(const EntryOperationData& in_entry_op, |
| net::IOBuffer* in_buf, |
| SimpleEntryStat* out_entry_stat, |
| int* out_result) const; |
| void CheckEOFRecord(int index, |
| - int data_size, |
| + const SimpleEntryStat& entry_stat, |
| uint32 expected_crc32, |
| int* out_result) const; |
| // Close all streams, and add write EOF records to streams indicated by the |
| // CRCRecord entries in |crc32s_to_write|. |
| void Close(const SimpleEntryStat& entry_stat, |
| - scoped_ptr<std::vector<CRCRecord> > crc32s_to_write); |
| + scoped_ptr<std::vector<CRCRecord> > crc32s_to_write, |
| + net::GrowableIOBuffer* stream_0_data); |
| const base::FilePath& path() const { return path_; } |
| std::string key() const { return key_; } |
| @@ -140,7 +163,10 @@ class SimpleSynchronousEntry { |
| // Returns a net error, i.e. net::OK on success. |had_index| is passed |
| // from the main entry for metrics purposes, and is true if the index was |
| // initialized when the open operation began. |
| - int InitializeForOpen(bool had_index, SimpleEntryStat* out_entry_stat); |
| + int InitializeForOpen(bool had_index, |
| + SimpleEntryStat* out_entry_stat, |
| + scoped_refptr<net::GrowableIOBuffer>* stream_0_data, |
| + uint32* out_stream_0_crc32); |
| // Returns a net error, including net::OK on success and net::FILE_EXISTS |
| // when the entry already exists. |had_index| is passed from the main entry |
| @@ -148,6 +174,19 @@ class SimpleSynchronousEntry { |
| // create operation began. |
| int InitializeForCreate(bool had_index, SimpleEntryStat* out_entry_stat); |
| + // Allocates and fills a buffer with stream 0 data in |stream_0_data|, then |
| + // checks its crc32. |
| + int ReadAndValidateStream0( |
| + int total_data_size, |
| + SimpleEntryStat* out_entry_stat, |
| + scoped_refptr<net::GrowableIOBuffer>* stream_0_data, |
| + uint32* out_stream_0_crc32) const; |
| + |
| + int GetEOFRecordData(int index, |
| + const SimpleEntryStat& entry_stat, |
| + bool* out_has_crc32, |
| + uint32* out_crc32, |
| + int* out_data_size) const; |
| void Doom() const; |
| static bool DeleteFilesForEntryHash(const base::FilePath& path, |