Chromium Code Reviews| Index: net/disk_cache/simple/simple_entry_impl.h |
| diff --git a/net/disk_cache/simple/simple_entry_impl.h b/net/disk_cache/simple/simple_entry_impl.h |
| index 544559480588c9f4d42cd6da1f0f2eccc5cbc2eb..e81d6ce97031b58f02dbe89a7e78ada4a6a29f44 100644 |
| --- a/net/disk_cache/simple/simple_entry_impl.h |
| +++ b/net/disk_cache/simple/simple_entry_impl.h |
| @@ -24,6 +24,7 @@ class TaskRunner; |
| } |
| namespace net { |
| +class GrowableIOBuffer; |
| class IOBuffer; |
| } |
| @@ -209,7 +210,7 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>, |
| int offset, |
| const CompletionCallback& completion_callback, |
| scoped_ptr<uint32> read_crc32, |
| - scoped_ptr<base::Time> last_used, |
| + scoped_ptr<SimpleEntryStat> entry_stat, |
| scoped_ptr<int> result); |
| // Called after an asynchronous write completes. |
| @@ -243,6 +244,14 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>, |
| void RecordReadIsParallelizable(const SimpleEntryOperation& operation) const; |
| void RecordWriteDependencyType(const SimpleEntryOperation& operation) const; |
| + // Reads from the stream 0 data kept in memory. |
| + int ReadStream0Data(net::IOBuffer* buf, int offset, int buf_len); |
| + |
| + // Copies stream 0 data to the buffer kept in memory. |
| + int CopyStream0Data(net::IOBuffer* buf, |
| + int offset, int buf_len, |
| + bool truncate); |
| + |
| // All nonstatic SimpleEntryImpl methods should always be called on the IO |
| // thread, in all cases. |io_thread_checker_| documents and enforces this. |
| base::ThreadChecker io_thread_checker_; |
| @@ -260,7 +269,7 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>, |
| // TODO(clamy): Unify last_used_ with data in the index. |
| base::Time last_used_; |
| base::Time last_modified_; |
| - int32 data_size_[kSimpleEntryFileCount]; |
| + int32 data_size_[kSimpleEntryStreamCount]; |
| // Number of times this object has been returned from Backend::OpenEntry() and |
| // Backend::CreateEntry() without subsequent Entry::Close() calls. Used to |
| @@ -273,15 +282,15 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>, |
| // write. For each stream, |crc32s_[index]| is the crc32 of that stream from |
| // [0 .. |crc32s_end_offset_|). If |crc32s_end_offset_[index] == 0| then the |
| // value of |crc32s_[index]| is undefined. |
| - int32 crc32s_end_offset_[kSimpleEntryFileCount]; |
| - uint32 crc32s_[kSimpleEntryFileCount]; |
| + int32 crc32s_end_offset_[kSimpleEntryStreamCount]; |
| + uint32 crc32s_[kSimpleEntryStreamCount]; |
| // If |have_written_[index]| is true, we have written to the stream |index|. |
| - bool have_written_[kSimpleEntryFileCount]; |
| + bool have_written_[kSimpleEntryStreamCount]; |
| // Reflects how much CRC checking has been done with the entry. This state is |
| // reported on closing each entry stream. |
| - CheckCrcResult crc_check_state_[kSimpleEntryFileCount]; |
| + CheckCrcResult crc_check_state_[kSimpleEntryStreamCount]; |
| // The |synchronous_entry_| is the worker thread object that performs IO on |
| // entries. It's owned by this SimpleEntryImpl whenever |executing_operation_| |
| @@ -296,6 +305,16 @@ class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl>, |
| net::BoundNetLog net_log_; |
| scoped_ptr<SimpleEntryOperation> executing_operation_; |
| + |
| + // Unlike other streams, stream 0 data is read from the disk when the entry is |
| + // opened, and then kept in memory. All read/write operations on stream 0 |
| + // affect the |stream_0_data_| buffer. When the entry is closed, |
| + // |stream_0_data_| is written to the disk. |
| + // Stream 0 is kept in memory because it is stored in the same file than |
| + // stream 1 on disk (to save diskspace). This strategy allows stream 1 to |
|
gavinp
2013/09/10 22:20:49
Stream 1 probably never needs to change size, thou
clamy
2013/09/11 12:46:21
Probably not, but the unit tests test it.
|
| + // change size easily. Since stream 0 is only used to write HTTP headers, the |
| + // memory consumption of keeping it in memory is acceptable. |
| + scoped_refptr<net::GrowableIOBuffer> stream_0_data_; |
| }; |
| } // namespace disk_cache |