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

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

Issue 2922973003: RFC: use some in-memory state in SimpleCache to quickly cache-miss some CantConditionalize cases
Patch Set: - Implement support for oracle bytes in MockHttpCache, so the code actually gets exercised in tests… Created 3 years, 6 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 afc18852a30f360778f51326459102dec6d7be94..8536ccec11816f3f640699a05f9fc12b31bfa0bf 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -205,6 +205,7 @@ void SimpleEntryImpl::SetActiveEntryProxy(
}
int SimpleEntryImpl::OpenEntry(Entry** out_entry,
+ const Backend::OracleCallback& oracle,
const CompletionCallback& callback) {
DCHECK(backend_.get());
@@ -219,8 +220,9 @@ int SimpleEntryImpl::OpenEntry(Entry** out_entry,
INDEX_MAX = 3,
};
OpenEntryIndexEnum open_entry_index_enum = INDEX_NOEXIST;
+ uint8_t oracle_byte = 0;
if (have_index) {
- if (backend_->index()->Has(entry_hash_))
+ if (backend_->index()->HasWithOracleByte(entry_hash_, &oracle_byte))
open_entry_index_enum = INDEX_HIT;
else
open_entry_index_enum = INDEX_MISS;
@@ -229,6 +231,14 @@ int SimpleEntryImpl::OpenEntry(Entry** out_entry,
"OpenEntryIndexState", cache_type_,
open_entry_index_enum, INDEX_MAX);
+ if (open_entry_index_enum == INDEX_HIT && !oracle.is_null() &&
+ oracle.Run(oracle_byte) == Backend::OracleJudgement::MISS_AND_DOOM) {
+ // ### UMA this.
+ // ### net log.
+ Doom();
+ return net::ERR_FAILED;
+ }
+
// If entry is not known to the index, initiate fast failover to the network.
if (open_entry_index_enum == INDEX_MISS) {
net_log_.AddEventWithNetErrorCode(
@@ -1363,6 +1373,13 @@ void SimpleEntryImpl::UpdateDataFromEntryStat(
}
}
+void SimpleEntryImpl::SetOracleByte(uint8_t oracle_byte) {
+ DCHECK(io_thread_checker_.CalledOnValidThread());
+ if (!doomed_ && backend_.get()) {
+ backend_->index()->UpdateEntryOracleByte(entry_hash_, oracle_byte);
+ }
+}
+
int64_t SimpleEntryImpl::GetDiskUsage() const {
int64_t file_size = 0;
for (int i = 0; i < kSimpleEntryStreamCount; ++i) {

Powered by Google App Engine
This is Rietveld 408576698