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

Unified Diff: net/disk_cache/simple/simple_entry_impl.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
Index: net/disk_cache/simple/simple_entry_impl.cc
diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc
index 62347507f8d8d61b2e272901670212bbe5399cbf..41a05a52b4e433769447799ccfa7de7476c6d82e 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -196,7 +196,8 @@ SimpleEntryImpl::SimpleEntryImpl(net::CacheType cache_type,
net_log_(
net::NetLogWithSource::Make(net_log,
net::NetLogSourceType::DISK_CACHE_ENTRY)),
- stream_0_data_(new net::GrowableIOBuffer()) {
+ stream_0_data_(new net::GrowableIOBuffer()),
+ stream_1_prefetch_data_(new net::GrowableIOBuffer()) {
static_assert(arraysize(data_size_) == arraysize(crc32s_end_offset_),
"arrays should be the same size");
static_assert(arraysize(data_size_) == arraysize(crc32s_),
@@ -557,7 +558,8 @@ size_t SimpleEntryImpl::EstimateMemoryUsage() const {
return sizeof(SimpleSynchronousEntry) +
base::trace_event::EstimateMemoryUsage(pending_operations_) +
base::trace_event::EstimateMemoryUsage(executing_operation_) +
- (stream_0_data_ ? stream_0_data_->capacity() : 0);
+ (stream_0_data_ ? stream_0_data_->capacity() : 0) +
+ (stream_1_prefetch_data_ ? stream_1_prefetch_data_->capacity() : 0);
}
SimpleEntryImpl::~SimpleEntryImpl() {
@@ -866,6 +868,8 @@ void SimpleEntryImpl::ReadDataInternal(int stream_index,
return;
}
+ // XXX(jkarlin): See if we can use the prefetch data for stream 1.
+
state_ = STATE_IO_PENDING;
if (!doomed_ && backend_.get())
backend_->index()->UseIfExists(entry_hash_);
@@ -1161,6 +1165,10 @@ void SimpleEntryImpl::CreationOperationComplete(
crc32s_[0] = in_results->stream_0_crc32;
crc32s_end_offset_[0] = in_results->entry_stat.data_size(0);
}
+ if (in_results->stream_1_prefetch_data.get()) {
+ stream_1_prefetch_data_ = in_results->stream_1_prefetch_data;
+ }
+
// If this entry was opened by hash, key_ could still be empty. If so, update
// it with the key read from the synchronous entry.
if (key_.empty()) {

Powered by Google App Engine
This is Rietveld 408576698