| Index: shell/child_process_host.h
|
| diff --git a/shell/child_process_host.h b/shell/child_process_host.h
|
| index f7eb65e4accff788eccd9308a53c1ff456bb664a..a6a0fb802e4f01ded8729b1f1082475d08bec51e 100644
|
| --- a/shell/child_process_host.h
|
| +++ b/shell/child_process_host.h
|
| @@ -5,25 +5,28 @@
|
| #ifndef SHELL_CHILD_PROCESS_HOST_H_
|
| #define SHELL_CHILD_PROCESS_HOST_H_
|
|
|
| +#include <stdint.h>
|
| +
|
| #include "base/macros.h"
|
| #include "base/process/process.h"
|
| +#include "mojo/edk/embedder/channel_info_forward.h"
|
| #include "mojo/edk/embedder/platform_channel_pair.h"
|
| #include "mojo/edk/embedder/scoped_platform_handle.h"
|
| +#include "mojo/public/cpp/bindings/error_handler.h"
|
| +#include "shell/app_child_process.mojom.h"
|
|
|
| namespace mojo {
|
| namespace shell {
|
|
|
| class Context;
|
|
|
| -// (Base) class for a "child process host". Handles launching and connecting a
|
| -// platform-specific "pipe" to the child, and supports joining the child
|
| -// process.
|
| +// Child process host: parent-process representation of a child process, which
|
| +// hosts/runs a native Mojo application loaded from the file system. This class
|
| +// handles launching and communicating with the child process.
|
| //
|
| // This class is not thread-safe. It should be created/used/destroyed on a
|
| // single thread.
|
| -//
|
| -// Note: Does not currently work on Windows before Vista.
|
| -class ChildProcessHost {
|
| +class ChildProcessHost : public ErrorHandler {
|
| public:
|
| explicit ChildProcessHost(Context* context);
|
| virtual ~ChildProcessHost();
|
| @@ -33,6 +36,8 @@ class ChildProcessHost {
|
| // After calling |Start()|, this object must not be destroyed until
|
| // |DidStart()| has been called.
|
| // TODO(vtl): Consider using weak pointers and removing this requirement.
|
| + // TODO(vtl): This should probably take a callback instead.
|
| + // TODO(vtl): Consider merging this with |StartApp()|.
|
| void Start();
|
|
|
| // Waits for the child process to terminate, and returns its exit code.
|
| @@ -40,28 +45,42 @@ class ChildProcessHost {
|
| // callback has been called.
|
| int Join();
|
|
|
| - embedder::ScopedPlatformHandle* platform_channel() {
|
| - return &platform_channel_;
|
| - }
|
| + // Methods relayed to the |AppChildController|. These methods may be only be
|
| + // called after |Start()|, but may be called immediately (without waiting for
|
| + // |DidStart()|).
|
|
|
| - virtual void WillStart() = 0;
|
| - virtual void DidStart(bool success) = 0;
|
| + // Like |AppChildController::StartApp()|, but with one difference:
|
| + // |on_app_complete| will *always* get called, even on connection error (or
|
| + // even if the child process failed to start at all).
|
| + void StartApp(const String& app_path,
|
| + bool clean_app_path,
|
| + InterfaceRequest<Application> application_request,
|
| + const AppChildController::StartAppCallback& on_app_complete);
|
| + void ExitNow(int32_t exit_code);
|
|
|
| - protected:
|
| - Context* context() const { return context_; }
|
| + // TODO(vtl): This is virtual, so tests can override it, but really |Start()|
|
| + // should take a callback (see above) and this should be private.
|
| + virtual void DidStart(bool success);
|
|
|
| private:
|
| + // Callback for |embedder::CreateChannel()|.
|
| + void DidCreateChannel(embedder::ChannelInfo* channel_info);
|
| +
|
| bool DoLaunch();
|
|
|
| - Context* const context_;
|
| + void AppCompleted(int32_t result);
|
|
|
| - base::Process child_process_;
|
| + // |ErrorHandler| methods:
|
| + void OnConnectionError() override;
|
|
|
| + Context* const context_;
|
| embedder::PlatformChannelPair platform_channel_pair_;
|
|
|
| - // Platform-specific "pipe" to the child process. Valid immediately after
|
| - // creation.
|
| - embedder::ScopedPlatformHandle platform_channel_;
|
| + AppChildControllerPtr controller_;
|
| + embedder::ChannelInfo* channel_info_;
|
| + AppChildController::StartAppCallback on_app_complete_;
|
| +
|
| + base::Process child_process_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ChildProcessHost);
|
| };
|
|
|