diff options
Diffstat (limited to 'net/disk_cache/simple/simple_entry_impl.cc')
-rw-r--r-- | net/disk_cache/simple/simple_entry_impl.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc index 6847e02..df1125c 100644 --- a/net/disk_cache/simple/simple_entry_impl.cc +++ b/net/disk_cache/simple/simple_entry_impl.cc @@ -368,6 +368,10 @@ void SimpleEntryImpl::CreateEntryInternal(Entry** out_entry, state_ = STATE_IO_PENDING; + // If creation succeeds, we should mark all streams to be saved on close. + for (int i = 0; i < kSimpleEntryFileCount; ++i) + have_written_[i] = true; + // We insert the entry in the index before creating the entry files in the // SimpleSynchronousEntry, because this way the worst scenario is when we // have the entry in the index but we don't have the created files yet, this @@ -401,10 +405,12 @@ void SimpleEntryImpl::CloseInternal() { crc32s_to_write(new std::vector<CRCRecord>()); for (int i = 0; i < kSimpleEntryFileCount; ++i) { if (have_written_[i]) { - if (data_size_[i] == crc32s_end_offset_[i]) - crc32s_to_write->push_back(CRCRecord(i, true, crc32s_[i])); - else + if (data_size_[i] == crc32s_end_offset_[i]) { + int32 crc = data_size_[i] == 0 ? crc32(0, Z_NULL, 0) : crc32s_[i]; + crc32s_to_write->push_back(CRCRecord(i, true, crc)); + } else { crc32s_to_write->push_back(CRCRecord(i, false, 0)); + } } } Closure task = base::Bind(&SimpleSynchronousEntry::Close, @@ -493,7 +499,7 @@ void SimpleEntryImpl::CreationOperationComplete( if (creation_failed) { completion_callback.Run(net::ERR_FAILED); MarkAsDoomed(); - state_ = STATE_UNINITIALIZED; + MakeUninitialized(); return; } state_ = STATE_READY; |