summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 16:31:10 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 16:31:10 +0000
commit1bf71ed8bf7b58f63101049a85e1d881802aa500 (patch)
treeb6c6b2bfd41f8d64a35d611145bc93946bc07081 /net
parent0aade3ea599e4720dcfa939fdcade766930c3ee6 (diff)
downloadchromium_src-1bf71ed8bf7b58f63101049a85e1d881802aa500.zip
chromium_src-1bf71ed8bf7b58f63101049a85e1d881802aa500.tar.gz
chromium_src-1bf71ed8bf7b58f63101049a85e1d881802aa500.tar.bz2
Reland 61124 - Disk Cache: Add a quick return path for truncating an empty stream
and make sure that Flush() doesn't fail when it has nothing to do. BUG=56872, 57395 TEST=none Review URL: http://codereview.chromium.org/3551005 Review URL: http://codereview.chromium.org/3576007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/disk_cache/entry_impl.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc
index 0655b28..24796ea 100644
--- a/net/disk_cache/entry_impl.cc
+++ b/net/disk_cache/entry_impl.cc
@@ -593,8 +593,10 @@ int EntryImpl::WriteDataImpl(int index, int offset, net::IOBuffer* buf,
}
Addr address(entry_.Data()->data_addr[index]);
- if (truncate && offset + buf_len == 0) {
- DCHECK(!address.is_initialized());
+ if (offset + buf_len == 0) {
+ if (truncate) {
+ DCHECK(!address.is_initialized());
+ }
return 0;
}
@@ -1010,6 +1012,9 @@ bool EntryImpl::PrepareTarget(int index, int offset, int buf_len,
if (truncate)
return HandleTruncation(index, offset, buf_len);
+ if (!offset && !buf_len)
+ return true;
+
Addr address(entry_.Data()->data_addr[index]);
if (address.is_initialized()) {
if (address.is_block_file() && !MoveToLocalBuffer(index))
@@ -1169,7 +1174,7 @@ bool EntryImpl::Flush(int index, int min_len) {
DCHECK(!address.is_initialized() || address.is_separate_file());
int size = std::max(entry_.Data()->data_size[index], min_len);
- if (!address.is_initialized() && !CreateDataBlock(index, size))
+ if (size && !address.is_initialized() && !CreateDataBlock(index, size))
return false;
if (!entry_.Data()->data_size[index]) {