summaryrefslogtreecommitdiffstats
path: root/net/http/http_cache_transaction.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-17 00:58:21 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-17 00:58:21 +0000
commit485cd456a503e6698c75ea6185ed93de832d493a (patch)
treed42875cbf1e55172a31c701c4825ff1e5726d943 /net/http/http_cache_transaction.cc
parent9ec84b6f69e5e3933fc4bb3e75ecf2771500a361 (diff)
downloadchromium_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/http/http_cache_transaction.cc')
-rw-r--r--net/http/http_cache_transaction.cc21
1 files changed, 10 insertions, 11 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;
}