[go: nahoru, domu]

Convert chromeos/process_proxy to base::Bind and base::Callback to Once/Repeating

Bug: 1007661
Change-Id: I4a88fa35c65c043c786a225a5f5fafaeeeb7548d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925188
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Toni Baržić <tbarzic@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716769}
diff --git a/chromeos/process_proxy/process_output_watcher_unittest.cc b/chromeos/process_proxy/process_output_watcher_unittest.cc
index 9bde562..7dfc294 100644
--- a/chromeos/process_proxy/process_output_watcher_unittest.cc
+++ b/chromeos/process_proxy/process_output_watcher_unittest.cc
@@ -111,7 +111,7 @@
 
   void OnRead(ProcessOutputType type,
               const std::string& output,
-              const base::Closure& ack_callback) {
+              base::OnceClosure ack_callback) {
     ASSERT_FALSE(failed_);
     // There may be an EXIT signal sent during test tear down (which is sent
     // by process output watcher when master end of test pseudo-terminal is
@@ -126,13 +126,13 @@
     if (failed_ || expectations_.IsDone()) {
       ASSERT_FALSE(test_case_done_callback_.is_null());
       task_environment_.GetMainThreadTaskRunner()->PostTask(
-          FROM_HERE, test_case_done_callback_);
+          FROM_HERE, std::move(test_case_done_callback_));
       test_case_done_callback_.Reset();
     }
 
     ASSERT_FALSE(ack_callback.is_null());
-    task_environment_.GetMainThreadTaskRunner()->PostTask(FROM_HERE,
-                                                          ack_callback);
+    task_environment_.GetMainThreadTaskRunner()->PostTask(
+        FROM_HERE, std::move(ack_callback));
   }
 
  protected:
@@ -153,10 +153,9 @@
     int pt_pipe[2];
     ASSERT_FALSE(HANDLE_EINTR(pipe(pt_pipe)));
 
-    std::unique_ptr<ProcessOutputWatcher> crosh_watcher(
-        new ProcessOutputWatcher(pt_pipe[0],
-                                 base::Bind(&ProcessOutputWatcherTest::OnRead,
-                                            base::Unretained(this))));
+    auto crosh_watcher = std::make_unique<ProcessOutputWatcher>(
+        pt_pipe[0], base::BindRepeating(&ProcessOutputWatcherTest::OnRead,
+                                        base::Unretained(this)));
 
     output_watch_thread_->task_runner()->PostTask(
         FROM_HERE, base::BindOnce(&ProcessOutputWatcher::Start,
@@ -192,7 +191,7 @@
   }
 
  private:
-  base::Closure test_case_done_callback_;
+  base::OnceClosure test_case_done_callback_;
   base::test::SingleThreadTaskEnvironment task_environment_;
   std::unique_ptr<base::Thread> output_watch_thread_;
   bool output_watch_thread_started_;