Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: net/disk_cache/simple/simple_synchronous_entry.h

Issue 2874833005: SimpleCache: read small files all at once. (Closed)
Patch Set: Add some metrics and an experiment knob. Not really happy with coverage, though. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 a7e6e66b12091847ed31623ecdebf1b41d008acc..5a2ffcee481ac5cfe2307f2212ba9d19f6cfe298 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.h
+++ b/net/disk_cache/simple/simple_synchronous_entry.h
@@ -79,8 +79,12 @@ struct SimpleEntryCreationResults {
SimpleSynchronousEntry* sync_entry;
scoped_refptr<net::GrowableIOBuffer> stream_0_data;
+
+ // |stream_1_data| may be null (in which case stream_1_crc32 will be unset)
+ scoped_refptr<net::GrowableIOBuffer> stream_1_data;
SimpleEntryStat entry_stat;
uint32_t stream_0_crc32;
+ uint32_t stream_1_crc32;
pasko 2017/07/18 13:46:31 are you packing this to make the sizeof(SimpleEntr
Maks Orlovich 2017/07/21 18:37:34 Done.
int result;
};
@@ -190,7 +194,7 @@ class SimpleSynchronousEntry {
int* out_result);
int CheckEOFRecord(int index,
const SimpleEntryStat& entry_stat,
- uint32_t expected_crc32) const;
+ uint32_t expected_crc32);
void ReadSparseData(const EntryOperationData& in_entry_op,
net::IOBuffer* out_buf,
@@ -282,7 +286,9 @@ class SimpleSynchronousEntry {
// Returns a net error, i.e. net::OK on success.
int InitializeForOpen(SimpleEntryStat* out_entry_stat,
scoped_refptr<net::GrowableIOBuffer>* stream_0_data,
- uint32_t* out_stream_0_crc32);
+ uint32_t* out_stream_0_crc32,
+ scoped_refptr<net::GrowableIOBuffer>* stream_1_data,
+ uint32_t* out_stream_1_crc32);
// Writes the header and key to a newly-created stream file. |index| is the
// index of the stream. Returns true on success; returns false and sets
@@ -294,19 +300,55 @@ class SimpleSynchronousEntry {
int InitializeForCreate(SimpleEntryStat* out_entry_stat);
// Allocates and fills a buffer with stream 0 data in |stream_0_data|, then
- // checks its crc32.
+ // checks its crc32. May also optionally read in |stream_1_data| and its
+ // crc, but might decide not to.
int ReadAndValidateStream0(
int file_size,
SimpleEntryStat* out_entry_stat,
scoped_refptr<net::GrowableIOBuffer>* stream_0_data,
- uint32_t* out_stream_0_crc32);
-
- int GetEOFRecordData(int index,
+ uint32_t* out_stream_0_crc32,
+ scoped_refptr<net::GrowableIOBuffer>* stream_1_data,
+ uint32_t* out_stream_1_crc32);
+
+ // Reads the EOF record for stream |stream_index| from the appropriate file,
+ // or in memory prefetched version in [prefetch_buf, prefetch_buf + file_size)
+ // using |entry_stat| for layout info, and putting result into
+ // |*eof_record|. Sanity-checks the result.
+ // Returns net status, and records any failures to UMA.
+ //
+ // Note that non-null |prefetch_buf| may only be specified if stream_index is
+ // 0 or 1.
+ int GetEOFRecordData(char* prefetch_buf,
+ int file_size,
+ int stream_index,
const SimpleEntryStat& entry_stat,
- bool* out_has_crc32,
- bool* out_has_key_sha256,
- uint32_t* out_crc32,
- int32_t* out_data_size) const;
+ SimpleFileEOF* eof_record);
+
+ // Reads either from |prefetch_buf| --- if that's not null --- or files_[0].
+ // Range-checks all the in-memory reads.
+ bool ReadFromFileOrPrefetched(char* prefetch_buf,
+ int file_size,
+ int offset,
+ int size,
+ char* dest);
+
+ // Extracts out the payload of stream |stream_index|, reading either from
+ // [prefetch_buf, prefetch_buf + file_size), if |prefetch_buf| is non-null,
+ // or the file. |entry_stat| will be used to determine file layout, though
+ // |extra_size| additional bytes will be read past the stream payload end.
+ //
+ // |*stream_data| will be pointed to a fresh buffer with the results,
+ // and |*out_crc32| will get the checksum, which will be verified against
+ // |eof_record|.
+ int PreReadStreamPayload(char* prefetch_buf,
+ int file_size,
+ int stream_index,
+ int extra_size,
+ const SimpleEntryStat& entry_stat,
+ const SimpleFileEOF& eof_record,
+ scoped_refptr<net::GrowableIOBuffer>* stream_data,
+ uint32_t* out_crc32);
+
void Doom() const;
// Opens the sparse data file and scans it if it exists.

Powered by Google App Engine
This is Rietveld 408576698