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

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: Added bug for test re: Android Created 5 years, 9 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
« no previous file with comments | « no previous file | content/browser/indexed_db/indexed_db_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « no previous file | content/browser/indexed_db/indexed_db_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698