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

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

Issue 2833673005: SimpleCache: comment a tricky bit of code. (Closed)
Patch Set: Just trying to avoid bogus dependency due to earlier screw up. Identical bits Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_synchronous_entry.cc
diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc
index 46dd750ed2ac783d2b57b098c89ea5f2f55d63e3..edda2087d136e7e0788c145c1db2b0400299bcf1 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.cc
+++ b/net/disk_cache/simple/simple_synchronous_entry.cc
@@ -1058,11 +1058,20 @@ int SimpleSynchronousEntry::InitializeForOpen(
if (empty_file_omitted_[i])
continue;
- if (!key_.empty()) {
- header_and_key_check_needed_[i] = true;
- } else {
+ if (key_.empty()) {
+ // If |key_| is empty, we were opened via the iterator interface, without
+ // knowing what our key is. We must therefore read the header immediately
+ // to discover it, so SimpleEntryImpl can make it available to
+ // disk_cache::Entry::GetKey().
if (!CheckHeaderAndKey(i))
return net::ERR_FAILED;
+ } else {
+ // If we do know which key were are looking for, we still need to
+ // check that the file actually has it (rather than just being a hash
+ // collision or some sort of file system accident), but that can be put
+ // off until opportune time: either the read of the footer, or when we
+ // start reading in the data, depending on stream # and format revision.
+ header_and_key_check_needed_[i] = true;
}
if (i == 0) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698