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

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

Issue 1977863003: SimpleCache: open with fewer seeks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@open-speeder-macbetter
Patch Set: remediate Created 4 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 48063f7817f7919d15f1dcba8574025fdd4e17d2..230c15de62ff514ba926dcabf23b779f5adaf98e 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -696,19 +696,13 @@ void SimpleEntryImpl::OpenEntryInternal(bool have_index,
std::unique_ptr<SimpleEntryCreationResults> results(
new SimpleEntryCreationResults(SimpleEntryStat(
last_used_, last_modified_, data_size_, sparse_data_size_)));
- Closure task = base::Bind(&SimpleSynchronousEntry::OpenEntry,
- cache_type_,
- path_,
- entry_hash_,
- have_index,
- results.get());
- Closure reply = base::Bind(&SimpleEntryImpl::CreationOperationComplete,
- this,
- callback,
- start_time,
- base::Passed(&results),
- out_entry,
- net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_OPEN_END);
+ Closure task =
+ base::Bind(&SimpleSynchronousEntry::OpenEntry, cache_type_, path_, key_,
+ entry_hash_, have_index, results.get());
+ Closure reply =
+ base::Bind(&SimpleEntryImpl::CreationOperationComplete, this, callback,
+ start_time, base::Passed(&results), out_entry,
+ net::NetLog::TYPE_SIMPLE_CACHE_ENTRY_OPEN_END);
worker_pool_->PostTaskAndReply(FROM_HERE, task, reply);
}
@@ -1147,13 +1141,10 @@ void SimpleEntryImpl::CreationOperationComplete(
crc32s_[0] = in_results->stream_0_crc32;
crc32s_end_offset_[0] = in_results->entry_stat.data_size(0);
}
- if (key_.empty()) {
+ // 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())
SetKey(synchronous_entry_->key());
- } else {
- // This should only be triggered when creating an entry. The key check in
- // the open case is handled in SimpleBackendImpl.
- DCHECK_EQ(key_, synchronous_entry_->key());
- }
Randy Smith (Not in Mondays) 2016/05/18 16:41:30 Why eliminate the DCHECK?
gavinp 2016/05/18 19:05:03 I put it back in, because an updated comment was d
UpdateDataFromEntryStat(in_results->entry_stat);
SIMPLE_CACHE_UMA(TIMES,
"EntryCreationTime", cache_type_,
@@ -1403,7 +1394,7 @@ int64_t SimpleEntryImpl::GetDiskUsage() const {
int64_t file_size = 0;
for (int i = 0; i < kSimpleEntryStreamCount; ++i) {
file_size +=
- simple_util::GetFileSizeFromKeyAndDataSize(key_, data_size_[i]);
+ simple_util::GetFileSizeFromDataSize(key_.size(), data_size_[i]);
}
file_size += sparse_data_size_;
return file_size;

Powered by Google App Engine
This is Rietveld 408576698