From dbc16ff05eb55788f4db456609d755cc1c6d56ea Mon Sep 17 00:00:00 2001 From: kylechar Date: Sat, 27 Apr 2019 05:15:02 +0900 Subject: Remove AdaptCallbackForRepeating() in ImportantFileWriter. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If posting the task fails then it's not an appropriate task runner. See https://crrev.com/c/1572809/3/base/files/important_file_writer.cc#258 for more context. Bug: 714018 Change-Id: I620bd978ec2a1d6b6219fa3d85ac6fbcd5563af2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1580041 Commit-Queue: kylechar Reviewed-by: François Doray Cr-Commit-Position: refs/heads/master@{#654577} CrOS-Libchrome-Original-Commit: c81955d58df6259b5751233400cd217258197543 --- base/files/important_file_writer.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'base') diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc index 2a9ef4f932..bb0c1a2a98 100644 --- a/base/files/important_file_writer.cc +++ b/base/files/important_file_writer.cc @@ -255,19 +255,15 @@ void ImportantFileWriter::WriteNow(std::unique_ptr data) { return; } - Closure task = AdaptCallbackForRepeating( + auto task = BindOnce(&WriteScopedStringToFileAtomically, path_, std::move(data), std::move(before_next_write_callback_), - std::move(after_next_write_callback_), histogram_suffix_)); + std::move(after_next_write_callback_), histogram_suffix_); - if (!task_runner_->PostTask(FROM_HERE, MakeCriticalClosure(task))) { - // 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. - NOTREACHED(); + // If PostTask() returns false, it means that |task_runner_| isn't + // BLOCK_SHUTDOWN and thus isn't appropriate to write an important file. + CHECK(task_runner_->PostTask(FROM_HERE, std::move(task))); - task.Run(); - } ClearPendingWrite(); } -- cgit v1.2.3