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

Unified Diff: net/http/http_cache.cc

Issue 2922973003: RFC: use some in-memory state in SimpleCache to quickly cache-miss some CantConditionalize cases
Patch Set: cleanup naming in SimpleCache impl of this some 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/http/http_cache.cc
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index eaaffe48c1bf538768e39d46bd5505b71f7e0614..8bc0a5407e8e42cb88fb87292a070ade0b249185 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -53,6 +53,12 @@
namespace net {
+namespace {
+
+void DoNothing(int rv) {}
+
+} // anonymous namespace
+
HttpCache::DefaultBackend::DefaultBackend(
CacheType type,
BackendType backend_type,
@@ -739,7 +745,8 @@ void HttpCache::DeletePendingOp(PendingOp* pending_op) {
delete pending_op;
}
-int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry,
+int HttpCache::OpenEntry(const std::string& key,
+ ActiveEntry** entry,
Transaction* trans) {
ActiveEntry* active_entry = FindActiveEntry(key);
if (active_entry) {
@@ -747,6 +754,13 @@ int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry,
return OK;
}
+ // See if we could potentially quick-reject the entry.
+ uint8_t in_memory_info = disk_cache_->GetMemoryEntryData(key);
+ if (trans->CanRejectBasedOnMemoryEntryData(in_memory_info)) {
+ disk_cache_->DoomEntry(key, base::Bind(DoNothing));
+ return net::ERR_FAILED;
Randy Smith (Not in Mondays) 2017/06/13 17:52:21 Won't this result in failing the consuming HttpCac
Maks Orlovich 2017/06/13 18:15:08 It's the same status a miss on OpenEntry would ret
+ }
+
std::unique_ptr<WorkItem> item =
base::MakeUnique<WorkItem>(WI_OPEN_ENTRY, trans, entry);
PendingOp* pending_op = GetPendingOp(key);

Powered by Google App Engine
This is Rietveld 408576698