Index: content/browser/indexed_db/indexed_db_backing_store.cc |
diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc |
index 4ae9ed4f236722b4c76dbcb62ee677b4223794c9..22bd411194f658a9aad10648cac8dc0592d06daf 100644 |
--- a/content/browser/indexed_db/indexed_db_backing_store.cc |
+++ b/content/browser/indexed_db/indexed_db_backing_store.cc |
@@ -2339,8 +2339,12 @@ class LocalWriteClosure : public FileWriterDelegate::DelegateWriteCallback, |
} |
bool success = write_status == FileWriterDelegate::SUCCESS_COMPLETED; |
- |
- if (success && !last_modified_.is_null()) { |
+ if (success && !bytes_written_) { |
+ // LocalFileStreamWriter only creates a file if data is actually written. |
+ // If none was then create one now. |
+ task_runner_->PostTask( |
+ FROM_HERE, base::Bind(&LocalWriteClosure::CreateEmptyFile, this)); |
+ } else if (success && !last_modified_.is_null()) { |
task_runner_->PostTask( |
FROM_HERE, base::Bind(&LocalWriteClosure::UpdateTimeStamp, this)); |
} else { |
@@ -2403,6 +2407,20 @@ class LocalWriteClosure : public FileWriterDelegate::DelegateWriteCallback, |
chained_blob_writer_->ReportWriteCompletion(true, bytes_written_); |
} |
+ // Create an empty file. |
+ void CreateEmptyFile() { |
+ DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
+ base::File file(file_path_, |
+ base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
+ bool success = file.created(); |
+ if (success && !last_modified_.is_null() && |
+ !file.SetTimes(last_modified_, last_modified_)) { |
+ // TODO(cmumford): Complain quietly; timestamp's probably not vital. |
+ } |
+ file.Close(); |
+ chained_blob_writer_->ReportWriteCompletion(success, bytes_written_); |
+ } |
+ |
scoped_refptr<IndexedDBBackingStore::Transaction::ChainedBlobWriter> |
chained_blob_writer_; |
scoped_refptr<base::SequencedTaskRunner> task_runner_; |