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/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index 894ac7d..264161c 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -217,13 +217,10 @@
PLOG(ERROR) << "Unable to set non-blocking I/O mode on fd " << progress_fd_;
}
- progress_task_ = MessageLoop::current()->WatchFileDescriptor(
- FROM_HERE,
+ progress_controller_ = base::FileDescriptorWatcher::WatchReadable(
progress_fd_,
- MessageLoop::WatchMode::kWatchRead,
- true,
- base::Bind(&PostinstallRunnerAction::OnProgressFdReady,
- base::Unretained(this)));
+ base::BindRepeating(&PostinstallRunnerAction::OnProgressFdReady,
+ base::Unretained(this)));
}
void PostinstallRunnerAction::OnProgressFdReady() {
@@ -248,8 +245,7 @@
if (!ok || eof) {
// There was either an error or an EOF condition, so we are done watching
// the file descriptor.
- MessageLoop::current()->CancelTask(progress_task_);
- progress_task_ = MessageLoop::kTaskIdNull;
+ progress_controller_.reset();
return;
}
} while (bytes_read);
@@ -293,10 +289,7 @@
fs_mount_dir_.clear();
progress_fd_ = -1;
- if (progress_task_ != MessageLoop::kTaskIdNull) {
- MessageLoop::current()->CancelTask(progress_task_);
- progress_task_ = MessageLoop::kTaskIdNull;
- }
+ progress_controller_.reset();
progress_buffer_.clear();
}