Shell: Remove ChildProcessHost::Delegate.
R=jamesr@chromium.org
Review URL: https://codereview.chromium.org/1050613002
diff --git a/shell/app_child_process_host.cc b/shell/app_child_process_host.cc
index 61951ac..3f97b5e 100644
--- a/shell/app_child_process_host.cc
+++ b/shell/app_child_process_host.cc
@@ -16,7 +16,7 @@
namespace shell {
AppChildProcessHost::AppChildProcessHost(Context* context)
- : ChildProcessHost(context, this), channel_info_(nullptr) {
+ : ChildProcessHost(context), channel_info_(nullptr) {
}
AppChildProcessHost::~AppChildProcessHost() {
diff --git a/shell/app_child_process_host.h b/shell/app_child_process_host.h
index 4fc7989..b7e237f 100644
--- a/shell/app_child_process_host.h
+++ b/shell/app_child_process_host.h
@@ -20,8 +20,7 @@
//
// Note: After |Start()|, |StartApp| must be called and this object must
// remained alive until the |on_app_complete| callback is called.
-class AppChildProcessHost : public ChildProcessHost,
- public ChildProcessHost::Delegate {
+class AppChildProcessHost : public ChildProcessHost {
public:
explicit AppChildProcessHost(Context* context);
~AppChildProcessHost() override;
@@ -33,7 +32,7 @@
const AppChildController::StartAppCallback& on_app_complete);
void ExitNow(int32_t exit_code);
- // |ChildProcessHost::Delegate| methods:
+ // |ChildProcessHost| methods:
void WillStart() override;
void DidStart(bool success) override;
diff --git a/shell/child_process_host.cc b/shell/child_process_host.cc
index 13a52b5..a88b3ed 100644
--- a/shell/child_process_host.cc
+++ b/shell/child_process_host.cc
@@ -20,9 +20,7 @@
namespace mojo {
namespace shell {
-ChildProcessHost::ChildProcessHost(Context* context, Delegate* delegate)
- : context_(context), delegate_(delegate) {
- DCHECK(delegate);
+ChildProcessHost::ChildProcessHost(Context* context) : context_(context) {
platform_channel_ = platform_channel_pair_.PassServerHandle();
CHECK(platform_channel_.is_valid());
}
@@ -37,12 +35,12 @@
void ChildProcessHost::Start() {
DCHECK(!child_process_.IsValid());
- delegate_->WillStart();
+ WillStart();
CHECK(base::PostTaskAndReplyWithResult(
context_->task_runners()->blocking_pool(), FROM_HERE,
base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this)),
- base::Bind(&ChildProcessHost::DidLaunch, base::Unretained(this))));
+ base::Bind(&ChildProcessHost::DidStart, base::Unretained(this))));
}
int ChildProcessHost::Join() {
@@ -87,9 +85,5 @@
return true;
}
-void ChildProcessHost::DidLaunch(bool success) {
- delegate_->DidStart(success);
-}
-
} // namespace shell
} // namespace mojo
diff --git a/shell/child_process_host.h b/shell/child_process_host.h
index 98909fa..fc4fff3 100644
--- a/shell/child_process_host.h
+++ b/shell/child_process_host.h
@@ -18,8 +18,7 @@
// (Base) class for a "child process host". Handles launching and connecting a
// platform-specific "pipe" to the child, and supports joining the child
-// process. Intended for use as a base class, but may be used on its own in
-// simple cases.
+// process.
//
// This class is not thread-safe. It should be created/used/destroyed on a
// single thread.
@@ -27,19 +26,13 @@
// Note: Does not currently work on Windows before Vista.
class ChildProcessHost {
public:
- class Delegate {
- public:
- virtual void WillStart() = 0;
- virtual void DidStart(bool success) = 0;
- };
-
- ChildProcessHost(Context* context, Delegate* delegate);
+ explicit ChildProcessHost(Context* context);
virtual ~ChildProcessHost();
- // |Start()|s the child process; calls the delegate's |DidStart()| (on the
- // thread on which |Start()| was called) when the child has been started (or
- // failed to start). After calling |Start()|, this object must not be
- // destroyed until |DidStart()| has been called.
+ // |Start()|s the child process; calls |DidStart()| (on the thread on which
+ // |Start()| was called) when the child has been started (or failed to start).
+ // After calling |Start()|, this object must not be destroyed until
+ // |DidStart()| has been called.
// TODO(vtl): Consider using weak pointers and removing this requirement.
void Start();
@@ -52,15 +45,16 @@
return &platform_channel_;
}
+ virtual void WillStart() = 0;
+ virtual void DidStart(bool success) = 0;
+
protected:
Context* context() const { return context_; }
private:
bool DoLaunch();
- void DidLaunch(bool success);
Context* const context_;
- Delegate* const delegate_;
base::Process child_process_;