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

Unified Diff: net/http/http_cache.cc

Issue 193043: Http cache: Don't delete sparse entries when we... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache.cc
===================================================================
--- net/http/http_cache.cc (revision 25640)
+++ net/http/http_cache.cc (working copy)
@@ -253,8 +253,9 @@
int EntryAvailable(ActiveEntry* entry);
// This transaction is being deleted and we are not done writing to the cache.
- // We need to indicate that the response data was truncated.
- void AddTruncatedFlag();
+ // We need to indicate that the response data was truncated. Returns true on
+ // success.
+ bool AddTruncatedFlag();
private:
// This is a helper function used to trigger a completion callback. It may
@@ -408,9 +409,9 @@
HttpCache::Transaction::~Transaction() {
if (!revoked()) {
if (entry_) {
- bool cancel_request = reading_ && !partial_.get() &&
- enable_range_support_ &&
- response_.headers->response_code() == 200;
+ bool cancel_request = reading_ && enable_range_support_;
+ if (cancel_request && !partial_.get())
+ cancel_request &= (response_.headers->response_code() == 200);
cache_->DoneWithEntry(entry_, this, cancel_request);
} else {
@@ -719,10 +720,20 @@
return rv;
}
-void HttpCache::Transaction::AddTruncatedFlag() {
+bool HttpCache::Transaction::AddTruncatedFlag() {
DCHECK(mode_ & WRITE);
+
+ // Don't set the flag for sparse entries.
+ if (partial_.get())
+ return true;
+
+ // Double check that there is something worth keeping.
+ if (!entry_->disk_entry->GetDataSize(kResponseContentIndex))
+ return false;
+
truncated_ = true;
WriteResponseInfoToEntry(true);
+ return true;
}
void HttpCache::Transaction::DoCallback(int rv) {
@@ -2003,11 +2014,7 @@
DCHECK(entry->disk_entry);
// This is a successful operation in the sense that we want to keep the
// entry.
- success = true;
- // Double check that there is something worth keeping.
- if (!entry->disk_entry->GetDataSize(kResponseContentIndex))
- success = false;
- trans->AddTruncatedFlag();
+ success = trans->AddTruncatedFlag();
}
DoneWritingToEntry(entry, success);
} else {
« no previous file with comments | « no previous file | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698