summaryrefslogtreecommitdiffstats
path: root/chrome/common/important_file_writer.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 21:21:55 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 21:21:55 +0000
commit6cad5bfd4d5ad1f3ebf80c53bf205459fdef8ee3 (patch)
tree4ab3eea10f7ce69ccd34ffd7d7371550ee05b190 /chrome/common/important_file_writer.cc
parent2cc0622486b85be1e098ecd2af563c0fa9743b26 (diff)
downloadchromium_src-6cad5bfd4d5ad1f3ebf80c53bf205459fdef8ee3.zip
chromium_src-6cad5bfd4d5ad1f3ebf80c53bf205459fdef8ee3.tar.gz
chromium_src-6cad5bfd4d5ad1f3ebf80c53bf205459fdef8ee3.tar.bz2
ImportantFileWriter: check return value of PostTask
when writing to the disk, so we can be sure it doesn't lose data. Also fix tests that misused things. TEST=none BUG=none Review URL: http://codereview.chromium.org/6627060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77695 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/important_file_writer.cc')
-rw-r--r--chrome/common/important_file_writer.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/chrome/common/important_file_writer.cc b/chrome/common/important_file_writer.cc
index ceac3fde..661f4ee 100644
--- a/chrome/common/important_file_writer.cc
+++ b/chrome/common/important_file_writer.cc
@@ -106,10 +106,19 @@ void ImportantFileWriter::WriteNow(const std::string& data) {
if (HasPendingWrite())
timer_.Stop();
- // TODO(sanjeevr): Add a DCHECK for the return value of PostTask.
- // (Some tests fail if we add the DCHECK and they need to be fixed first).
- file_message_loop_proxy_->PostTask(FROM_HERE,
- new WriteToDiskTask(path_, data));
+ if (!file_message_loop_proxy_->PostTask(FROM_HERE,
+ new WriteToDiskTask(path_, data))) {
+ // Posting the task to background message loop is not expected
+ // to fail, but if it does, avoid losing data and just hit the disk
+ // on the current thread.
+ // TODO(phajdan.jr): Fix test failures on Win and enable code below.
+#if !defined(OS_WIN)
+ NOTREACHED();
+
+ WriteToDiskTask write_task(path_, data);
+ write_task.Run();
+#endif
+ }
}
void ImportantFileWriter::ScheduleWrite(DataSerializer* serializer) {