shill: ExternalTask: use ProcessManager to manage processes
This removes glib dependency for spawning/monitoring processes
for external tasks.
This is a part of series CLs that convert shill over to MessageLoopForIO
and chromeos dbus.
BUG=chromium:516841
TEST=unittests
Change-Id: I6cec2326671bf0da09cd8ec7731b5c510cbed0ed
Reviewed-on: https://chromium-review.googlesource.com/292982
Commit-Ready: Zeping Qiu <zqiu@chromium.org>
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: Zeping Qiu <zqiu@chromium.org>
diff --git a/external_task.h b/external_task.h
index 8fdf60f..2880dd7 100644
--- a/external_task.h
+++ b/external_task.h
@@ -17,7 +17,6 @@
#include <base/memory/weak_ptr.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
-#include "shill/glib.h"
#include "shill/rpc_task.h"
namespace shill {
@@ -25,12 +24,12 @@
class ControlInterface;
class Error;
class EventDispatcher;
-class ProcessKiller;
+class ProcessManager;
class ExternalTask : public RPCTaskDelegate {
public:
ExternalTask(ControlInterface* control,
- GLib* glib,
+ ProcessManager* process_manager,
const base::WeakPtr<RPCTaskDelegate>& task_delegate,
const base::Callback<void(pid_t, int)>& death_callback);
~ExternalTask() override; // But consider DestroyLater...
@@ -90,19 +89,14 @@
void Notify(
const std::string& event,
const std::map<std::string, std::string>& details) override;
+
// Called when the external process exits.
- static void OnTaskDied(GPid pid, gint status, gpointer data);
+ void OnTaskDied(int exit_status);
static void Destroy(ExternalTask* task);
- // This method is run in the child process (i.e. after fork(), but
- // before exec()). It configures the child to receive a SIGTERM when
- // the parent exits.
- static void SetupTermination(gpointer glib_user_data);
-
ControlInterface* control_;
- GLib* glib_;
- ProcessKiller* process_killer_; // Field permits mocking.
+ ProcessManager* process_manager_;
std::unique_ptr<RPCTask> rpc_task_;
base::WeakPtr<RPCTaskDelegate> task_delegate_;
@@ -112,9 +106,6 @@
// spawned yet or the process has died.
pid_t pid_;
- // Child exit watch callback source tag.
- unsigned int child_watch_tag_;
-
DISALLOW_COPY_AND_ASSIGN(ExternalTask);
};