Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: content/browser/indexed_db/indexed_db_backing_store.cc

Issue 942633004: IndexedDB: Fixed support for empty blobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Backing store now creating empty file + test. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_;

Powered by Google App Engine
This is Rietveld 408576698