diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-17 00:58:21 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-17 00:58:21 +0000 |
commit | 485cd456a503e6698c75ea6185ed93de832d493a (patch) | |
tree | d42875cbf1e55172a31c701c4825ff1e5726d943 /net | |
parent | 9ec84b6f69e5e3933fc4bb3e75ecf2771500a361 (diff) | |
download | chromium_src-485cd456a503e6698c75ea6185ed93de832d493a.zip chromium_src-485cd456a503e6698c75ea6185ed93de832d493a.tar.gz chromium_src-485cd456a503e6698c75ea6185ed93de832d493a.tar.bz2 |
Http Cache: Make sure that we don't fail transactions when the
disk cache fails (now on an async world).
BUG=49216
TEST=net_unittests
Review URL: http://codereview.chromium.org/2812062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_cache_transaction.cc | 21 | ||||
-rw-r--r-- | net/http/http_cache_transaction.h | 1 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 6 |
3 files changed, 15 insertions, 13 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc index f524c60..2ea08b8 100644 --- a/net/http/http_cache_transaction.cc +++ b/net/http/http_cache_transaction.cc @@ -109,6 +109,7 @@ HttpCache::Transaction::Transaction(HttpCache* cache, bool enable_range_support) cache_pending_(false), read_offset_(0), effective_load_flags_(0), + write_len_(0), final_upload_progress_(0), ALLOW_THIS_IN_INITIALIZER_LIST( io_callback_(this, &Transaction::OnIOComplete)), @@ -1174,6 +1175,7 @@ int HttpCache::Transaction::DoCacheReadDataComplete(int result) { int HttpCache::Transaction::DoCacheWriteData(int num_bytes) { next_state_ = STATE_CACHE_WRITE_DATA_COMPLETE; + write_len_ = num_bytes; cache_callback_->AddRef(); // Balanced in DoCacheWriteDataComplete. return AppendResponseDataToEntry(read_buf_, num_bytes, cache_callback_); @@ -1185,8 +1187,14 @@ int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { if (!cache_) return ERR_UNEXPECTED; - if (result < 0) - return result; + if (result != write_len_) { + DLOG(ERROR) << "failed to write response data to cache"; + DoneWritingToEntry(false); + + // We want to ignore errors writing to disk and just keep reading from + // the network. + result = write_len_; + } if (partial_.get()) { // This may be the last request. @@ -1725,15 +1733,6 @@ int HttpCache::Transaction::WriteToEntry(int index, int offset, } else { rv = partial_->CacheWrite(entry_->disk_entry, data, data_len, callback); } - - if (rv != ERR_IO_PENDING && rv != data_len) { - DLOG(ERROR) << "failed to write response data to cache"; - DoneWritingToEntry(false); - - // We want to ignore errors writing to disk and just keep reading from - // the network. - rv = data_len; - } return rv; } diff --git a/net/http/http_cache_transaction.h b/net/http/http_cache_transaction.h index f19f76a..ae143e9 100644 --- a/net/http/http_cache_transaction.h +++ b/net/http/http_cache_transaction.h @@ -339,6 +339,7 @@ class HttpCache::Transaction : public HttpTransaction { int io_buf_len_; int read_offset_; int effective_load_flags_; + int write_len_; scoped_ptr<PartialData> partial_; // We are dealing with range requests. uint64 final_upload_progress_; CompletionCallbackImpl<Transaction> io_callback_; diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index c3ee0a0..8b2f7cc 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -137,8 +137,10 @@ class MockDiskEntry : public disk_cache::Entry, DCHECK(callback); DCHECK(truncate); - if (fail_requests_) - return net::ERR_CACHE_READ_FAILURE; + if (fail_requests_) { + CallbackLater(callback, net::ERR_CACHE_READ_FAILURE); + return net::ERR_IO_PENDING; + } if (offset < 0 || offset > static_cast<int>(data_[index].size())) return net::ERR_FAILED; |