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

Unified Diff: base/test/launcher/test_launcher.cc

Issue 2384273002: Use FileDescriptorWatcher in base::TestLauncher. (Closed)
Patch Set: fix win_clang Created 4 years, 2 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 | « no previous file | base/test/launcher/test_launcher_nacl_nonsfi.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/launcher/test_launcher.cc
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index 0d2151fd54a8f248eb851d53a2933f291a84d44e..4b86c5621a938f7b57b7c2300ffa5437e1a9e6c8 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -47,6 +47,8 @@
#if defined(OS_POSIX)
#include <fcntl.h>
+
+#include "base/files/file_descriptor_watcher_posix.h"
#endif
#if defined(OS_MACOSX)
@@ -152,26 +154,15 @@ void KillSpawnedTestProcesses() {
// I/O watcher for the reading end of the self-pipe above.
// Terminates any launched child processes and exits the process.
-class SignalFDWatcher : public MessageLoopForIO::Watcher {
- public:
- SignalFDWatcher() {
- }
-
- void OnFileCanReadWithoutBlocking(int fd) override {
- fprintf(stdout, "\nCaught signal. Killing spawned test processes...\n");
- fflush(stdout);
-
- KillSpawnedTestProcesses();
-
- // The signal would normally kill the process, so exit now.
- _exit(1);
- }
+void OnShutdownPipeReadable() {
+ fprintf(stdout, "\nCaught signal. Killing spawned test processes...\n");
+ fflush(stdout);
- void OnFileCanWriteWithoutBlocking(int fd) override { NOTREACHED(); }
+ KillSpawnedTestProcesses();
- private:
- DISALLOW_COPY_AND_ASSIGN(SignalFDWatcher);
-};
+ // The signal would normally kill the process, so exit now.
+ _exit(1);
+}
#endif // defined(OS_POSIX)
// Parses the environment variable var as an Int32. If it is unset, returns
@@ -530,15 +521,8 @@ bool TestLauncher::Run() {
CHECK_EQ(0, sigaction(SIGQUIT, &action, NULL));
CHECK_EQ(0, sigaction(SIGTERM, &action, NULL));
- MessageLoopForIO::FileDescriptorWatcher controller;
- SignalFDWatcher watcher;
-
- CHECK(MessageLoopForIO::current()->WatchFileDescriptor(
- g_shutdown_pipe[0],
- true,
- MessageLoopForIO::WATCH_READ,
- &controller,
- &watcher));
+ auto controller = base::FileDescriptorWatcher::WatchReadable(
+ g_shutdown_pipe[0], base::Bind(&OnShutdownPipeReadable));
#endif // defined(OS_POSIX)
// Start the watchdog timer.
« no previous file with comments | « no previous file | base/test/launcher/test_launcher_nacl_nonsfi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698