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..2d32e5810f17ef51d88feac20426f7f16ff3b0a2 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); |
+ |
// 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,16 @@ 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|. |
- bool have_written_[kSimpleEntryFileCount]; |
+ // If |have_written_[index]| is true, we have written to the file that |
+ // contains stream |index|. |
+ 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 +316,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 |
+ // stream 1 on disk (to save diskspace). This strategy allows stream 1 to |
gavinp
2013/09/17 15:07:43
Nit: disk space is two words.
clamy
2013/09/18 16:17:15
Done.
|
+ // 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 |