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 d7d9b8f942a06ae6373b764b2358116e9353092b..d0f3c34aa3ca70a5af1160cbf5d7419090976896 100644 |
| --- a/net/disk_cache/simple/simple_entry_impl.h |
| +++ b/net/disk_cache/simple/simple_entry_impl.h |
| @@ -25,6 +25,7 @@ class TaskRunner; |
| } |
| namespace net { |
| +class GrowableIOBuffer; |
| class IOBuffer; |
| } |
| @@ -217,7 +218,7 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry, |
| 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. |
| @@ -251,6 +252,14 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry, |
| 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); |
|
pasko
2013/09/17 14:17:36
since this function does not change the state of |
clamy
2013/09/18 16:17:14
net::IOBuffer::data() is not const, and used in th
|
| + |
| // 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_; |
| @@ -268,7 +277,7 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry, |
| // 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 |
| @@ -283,15 +292,15 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry, |
| // 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|. |
|
Deprecated (see juliatuttle)
2013/09/16 20:01:52
This comment is no longer strictly true; we set ha
clamy
2013/09/17 13:59:42
Done.
|
| - 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_| |
| @@ -306,6 +315,16 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry, |
| 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 |
|
pasko
2013/09/17 14:17:36
s/than/as/
s/(to save diskspace)// <-- since we a
clamy
2013/09/18 16:17:14
Done.
|
| + // stream 1 on disk (to save diskspace). This strategy allows stream 1 to |
| + // 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 |