diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-09 16:55:22 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-09 16:55:22 +0000 |
commit | 2c85285301170a722fe10c8699c82644973e3f8d (patch) | |
tree | a3c1e1b5304c40e1daeca843b6efd517d2a5d89f /net/http/http_cache.cc | |
parent | 2b653c6fe6c0d464e98960f46d933abf16769423 (diff) | |
download | chromium_src-2c85285301170a722fe10c8699c82644973e3f8d.zip chromium_src-2c85285301170a722fe10c8699c82644973e3f8d.tar.gz chromium_src-2c85285301170a722fe10c8699c82644973e3f8d.tar.bz2 |
Http cache: Don't delete sparse entries when we
cancel the request.
BUG=20930
TEST=unittests
Review URL: http://codereview.chromium.org/193043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache.cc')
-rw-r--r-- | net/http/http_cache.cc | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index 35d51478..9cb9786 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -253,8 +253,9 @@ class HttpCache::Transaction 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 @@ class HttpCache::Transaction 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 @@ int HttpCache::Transaction::EntryAvailable(ActiveEntry* entry) { 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 @@ void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans, 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 { |