update_engine: Replace FileWatcher.
base::MessageLoop::WatchFileDescriptor() is removed in the next uprev.
This CL replaces the uses (including indirect uses), by FileDescriptorWatcher.
BUG=chromium:909719
TEST=Built locally. Ran cros_run_unit_tests.
Change-Id: Ide9f94daf2be28696ec6bc1f82ab46a2bd2b6c6f
diff --git a/common/subprocess.cc b/common/subprocess.cc
index 0131f10..36655c7 100644
--- a/common/subprocess.cc
+++ b/common/subprocess.cc
@@ -127,8 +127,7 @@
if (!ok || eof) {
// There was either an error or an EOF condition, so we are done watching
// the file descriptor.
- MessageLoop::current()->CancelTask(record->stdout_task_id);
- record->stdout_task_id = MessageLoop::kTaskIdNull;
+ record->stdout_controller.reset();
return;
}
} while (bytes_read);
@@ -143,8 +142,7 @@
// Make sure we read any remaining process output and then close the pipe.
OnStdoutReady(record);
- MessageLoop::current()->CancelTask(record->stdout_task_id);
- record->stdout_task_id = MessageLoop::kTaskIdNull;
+ record->stdout_controller.reset();
// Don't print any log if the subprocess exited with exit code 0.
if (info.si_code != CLD_EXITED) {
@@ -199,12 +197,9 @@
<< record->stdout_fd << ".";
}
- record->stdout_task_id = MessageLoop::current()->WatchFileDescriptor(
- FROM_HERE,
+ record->stdout_controller = base::FileDescriptorWatcher::WatchReadable(
record->stdout_fd,
- MessageLoop::WatchMode::kWatchRead,
- true,
- base::Bind(&Subprocess::OnStdoutReady, record.get()));
+ base::BindRepeating(&Subprocess::OnStdoutReady, record.get()));
subprocess_records_[pid] = std::move(record);
return pid;