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

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

Issue 2872943002: [SimpleCache] Prefetch stream 1 so that the first read is faster
Patch Set: Created 3 years, 7 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
« no previous file with comments | « net/disk_cache/simple/simple_synchronous_entry.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_synchronous_entry.cc
diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc
index ea83472455e9170d7f0bb178fa6ee934bb09d6fd..befb614f5e2b6d222b45b5089f27d54bba604857 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.cc
+++ b/net/disk_cache/simple/simple_synchronous_entry.cc
@@ -268,12 +268,13 @@ void SimpleSynchronousEntry::OpenEntry(
new SimpleSynchronousEntry(cache_type, path, key, entry_hash, had_index);
out_results->result = sync_entry->InitializeForOpen(
&out_results->entry_stat, &out_results->stream_0_data,
- &out_results->stream_0_crc32);
+ &out_results->stream_0_crc32, &out_results->stream_1_prefetch_data);
if (out_results->result != net::OK) {
sync_entry->Doom();
delete sync_entry;
- out_results->sync_entry = NULL;
- out_results->stream_0_data = NULL;
+ out_results->sync_entry = nullptr;
+ out_results->stream_0_data = nullptr;
+ out_results->stream_1_prefetch_data = nullptr;
return;
}
SIMPLE_CACHE_UMA(TIMES, "DiskOpenLatency", cache_type,
@@ -1079,12 +1080,14 @@ bool SimpleSynchronousEntry::CheckHeaderAndKey(int file_index) {
int SimpleSynchronousEntry::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_prefetch_data) {
DCHECK(!initialized_);
if (!OpenFiles(out_entry_stat)) {
DLOG(WARNING) << "Could not open platform files for entry.";
return net::ERR_FAILED;
}
+ bool iterator_open = false;
for (int i = 0; i < kSimpleEntryFileCount; ++i) {
if (empty_file_omitted_[i])
continue;
@@ -1094,6 +1097,7 @@ int SimpleSynchronousEntry::InitializeForOpen(
// knowing what our key is. We must therefore read the header immediately
// to discover it, so SimpleEntryImpl can make it available to
// disk_cache::Entry::GetKey().
+ iterator_open = true;
if (!CheckHeaderAndKey(i))
return net::ERR_FAILED;
} else {
@@ -1148,6 +1152,33 @@ int SimpleSynchronousEntry::InitializeForOpen(
RecordSyncOpenResult(cache_type_, OPEN_ENTRY_SUCCESS, had_index_);
initialized_ = true;
+
+ // If there is data to read and it's not partial, read some.
+ if (out_entry_stat->sparse_data_size() == 0 &&
jkarlin 2017/05/09 15:56:45 The bits in this conditional are completely broken
+ out_entry_stat->data_size(1) > 0) {
+ // Figure out if we should be computing the checksum for this read,
+ // and whether we should be verifying it, too.
+ std::unique_ptr<CRCRequest> crc_request;
+ if (crc32s_end_offset_[stream_index] == 0) {
+ crc_request = base::MakeUnique<CRCRequest>();
+ crc_request->data_crc32 = crc32(0, Z_NULL, 0);
+ crc_request->request_verify = true;
+ }
+
+ std::unique_ptr<int> result = base::MakeUnique<int>(0);
+ std::unique_ptr<SimpleEntryStat> entry_stat =
+ base::MakeUnique<SimpleEntryStat>(last_used_, last_modified_,
+ data_size_, sparse_data_size_);
+ Closure task = base::Bind(&SimpleSynchronousEntry::ReadData,
+ base::Unretained(synchronous_entry_),
+ SimpleSynchronousEntry::EntryOperationData(
+ stream_index, offset, buf_len),
+ crc_request.get(), entry_stat.get(),
+ base::RetainedRef(buf), result.get());
+
+ ReadData
+ }
+
return net::OK;
}
« no previous file with comments | « net/disk_cache/simple/simple_synchronous_entry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698