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

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: - 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/http/http_cache.cc
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index eaaffe48c1bf538768e39d46bd5505b71f7e0614..8e55ef64c3de27ea873aa46832ac0d2c1ddbe8f3 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -739,7 +739,9 @@ 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,
+ disk_cache::Backend::OracleCallback oracle_callback,
Transaction* trans) {
ActiveEntry* active_entry = FindActiveEntry(key);
if (active_entry) {
@@ -747,6 +749,7 @@ int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry,
return OK;
}
+ // ### store the oracle callback in this case?
std::unique_ptr<WorkItem> item =
base::MakeUnique<WorkItem>(WI_OPEN_ENTRY, trans, entry);
PendingOp* pending_op = GetPendingOp(key);
@@ -761,8 +764,13 @@ int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry,
pending_op->callback = base::Bind(&HttpCache::OnPendingOpComplete,
GetWeakPtr(), pending_op);
- int rv = disk_cache_->OpenEntry(key, &(pending_op->disk_entry),
- pending_op->callback);
+ int rv;
+ if (oracle_callback.is_null())
+ rv = disk_cache_->OpenEntry(key, &(pending_op->disk_entry),
+ pending_op->callback);
+ else
+ rv = disk_cache_->OpenEntryWithOracleByte(
+ key, &(pending_op->disk_entry), oracle_callback, pending_op->callback);
if (rv != ERR_IO_PENDING) {
pending_op->writer->ClearTransaction();
pending_op->callback.Run(rv);

Powered by Google App Engine
This is Rietveld 408576698