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..fdc072826a6490d40e81ad00ac08a08cd5a2a454 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. |
michaeln
2015/03/06 22:31:38
nit: the first line of this comment is enough
|
+ 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,19 @@ class LocalWriteClosure : public FileWriterDelegate::DelegateWriteCallback, |
chained_blob_writer_->ReportWriteCompletion(true, bytes_written_); |
} |
+ // Create an empty file. |
michaeln
2015/03/06 22:31:38
this comment probably isn't needed
|
+ void CreateEmptyFile() { |
+ DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
+ base::File file(file_path_, |
+ base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
+ bool success = file.created(); |
+ file.Close(); |
+ if (success && !last_modified_.is_null()) |
+ UpdateTimeStamp(); |
+ else |
+ chained_blob_writer_->ReportWriteCompletion(success, bytes_written_); |
+ } |
+ |
scoped_refptr<IndexedDBBackingStore::Transaction::ChainedBlobWriter> |
chained_blob_writer_; |
scoped_refptr<base::SequencedTaskRunner> task_runner_; |