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

Unified Diff: base/files/important_file_writer.cc

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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 | « base/files/important_file_writer.h ('k') | base/mac/libdispatch_task_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/important_file_writer.cc
diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc
index edd400ce183f13fada7f89ad861c95e5510f7d55..973e3c2bdf10324ac74498f2f4f6a7e6ef96a04a 100644
--- a/base/files/important_file_writer.cc
+++ b/base/files/important_file_writer.cc
@@ -209,7 +209,7 @@ void ImportantFileWriter::RegisterOnNextSuccessfulWriteCallback(
on_next_successful_write_ = on_next_successful_write;
}
-bool ImportantFileWriter::PostWriteTask(const Callback<bool()>& task) {
+bool ImportantFileWriter::PostWriteTask(OnceCallback<bool()> task) {
// TODO(gab): This code could always use PostTaskAndReplyWithResult and let
// ForwardSuccessfulWrite() no-op if |on_next_successful_write_| is null, but
// PostTaskAndReply causes memory leaks in tests (crbug.com/371974) and
@@ -217,15 +217,13 @@ bool ImportantFileWriter::PostWriteTask(const Callback<bool()>& task) {
// using PostTask() in the typical scenario below.
if (!on_next_successful_write_.is_null()) {
return PostTaskAndReplyWithResult(
- task_runner_.get(),
- FROM_HERE,
- MakeCriticalClosure(task),
+ task_runner_.get(), FROM_HERE, MakeCriticalClosure(std::move(task)),
Bind(&ImportantFileWriter::ForwardSuccessfulWrite,
weak_factory_.GetWeakPtr()));
}
return task_runner_->PostTask(
FROM_HERE,
- MakeCriticalClosure(Bind(IgnoreResult(task))));
+ MakeCriticalClosure(BindOnce(IgnoreResult(std::move(task)))));
}
void ImportantFileWriter::ForwardSuccessfulWrite(bool result) {
« no previous file with comments | « base/files/important_file_writer.h ('k') | base/mac/libdispatch_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698