| Index: mojo/runner/child/runner_connection.cc
|
| diff --git a/mojo/runner/child/runner_connection.cc b/mojo/runner/child/runner_connection.cc
|
| index ca0c7fc808082f4fdfa04d3e1fa916056308de9a..c7758c41141d271f28aa5e796e7d497e07dbaeab 100644
|
| --- a/mojo/runner/child/runner_connection.cc
|
| +++ b/mojo/runner/child/runner_connection.cc
|
| @@ -23,8 +23,6 @@
|
| namespace runner {
|
| namespace {
|
|
|
| -void DidCreateChannel(embedder::ChannelInfo* channel_info) {}
|
| -
|
| // Blocks a thread until another thread unblocks it, at which point it unblocks
|
| // and runs a closure provided by that thread.
|
| class Blocker {
|
| @@ -91,8 +89,7 @@
|
|
|
| // Returns true if a connection to the runner has been established and
|
| // |request| has been modified, false if no connection was established.
|
| - bool WaitForApplicationRequest(InterfaceRequest<Application>* request,
|
| - ScopedMessagePipeHandle handle);
|
| + bool WaitForApplicationRequest(InterfaceRequest<Application>* request);
|
|
|
| ChildControllerImpl* controller() const { return controller_.get(); }
|
|
|
| @@ -136,15 +133,23 @@
|
| // etc.
|
| static void Create(RunnerConnectionImpl* connection,
|
| const GotApplicationRequestCallback& callback,
|
| - ScopedMessagePipeHandle runner_handle,
|
| + embedder::ScopedPlatformHandle platform_channel,
|
| const Blocker::Unblocker& unblocker) {
|
| DCHECK(connection);
|
| + DCHECK(platform_channel.is_valid());
|
| +
|
| DCHECK(!connection->controller());
|
|
|
| scoped_ptr<ChildControllerImpl> impl(
|
| new ChildControllerImpl(connection, callback, unblocker));
|
|
|
| - impl->Bind(runner_handle.Pass());
|
| + ScopedMessagePipeHandle host_message_pipe(embedder::CreateChannel(
|
| + platform_channel.Pass(),
|
| + base::Bind(&ChildControllerImpl::DidCreateChannel,
|
| + base::Unretained(impl.get())),
|
| + base::ThreadTaskRunnerHandle::Get()));
|
| +
|
| + impl->Bind(host_message_pipe.Pass());
|
|
|
| connection->set_controller(impl.Pass());
|
| }
|
| @@ -186,6 +191,13 @@
|
| binding_.set_connection_error_handler([this]() { OnConnectionError(); });
|
| }
|
|
|
| + // Callback for |embedder::CreateChannel()|.
|
| + void DidCreateChannel(embedder::ChannelInfo* channel_info) {
|
| + DVLOG(2) << "ChildControllerImpl::DidCreateChannel()";
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + channel_info_ = channel_info;
|
| + }
|
| +
|
| static void ReturnApplicationRequestOnMainThread(
|
| const GotApplicationRequestCallback& callback,
|
| InterfaceRequest<Application> application_request) {
|
| @@ -205,20 +217,12 @@
|
| };
|
|
|
| bool RunnerConnectionImpl::WaitForApplicationRequest(
|
| - InterfaceRequest<Application>* request,
|
| - ScopedMessagePipeHandle handle) {
|
| - // If a valid message pipe to the runner was not provided, look for one on the
|
| - // command line.
|
| - if (!handle.is_valid()) {
|
| - embedder::ScopedPlatformHandle platform_channel =
|
| - embedder::PlatformChannelPair::PassClientHandleFromParentProcess(
|
| - *base::CommandLine::ForCurrentProcess());
|
| - if (!platform_channel.is_valid())
|
| - return false;
|
| - handle = embedder::CreateChannel(platform_channel.Pass(),
|
| - base::Bind(&DidCreateChannel),
|
| - base::ThreadTaskRunnerHandle::Get());
|
| - }
|
| + InterfaceRequest<Application>* request) {
|
| + embedder::ScopedPlatformHandle platform_channel =
|
| + embedder::PlatformChannelPair::PassClientHandleFromParentProcess(
|
| + *base::CommandLine::ForCurrentProcess());
|
| + if (!platform_channel.is_valid())
|
| + return false;
|
|
|
| Blocker blocker;
|
| controller_runner_->PostTask(
|
| @@ -226,7 +230,7 @@
|
| base::Bind(
|
| &ChildControllerImpl::Create, base::Unretained(this),
|
| base::Bind(&OnGotApplicationRequest, base::Unretained(request)),
|
| - base::Passed(&handle), blocker.GetUnblocker()));
|
| + base::Passed(&platform_channel), blocker.GetUnblocker()));
|
| blocker.Block();
|
|
|
| return true;
|
| @@ -238,10 +242,9 @@
|
|
|
| // static
|
| RunnerConnection* RunnerConnection::ConnectToRunner(
|
| - InterfaceRequest<Application>* request,
|
| - ScopedMessagePipeHandle handle) {
|
| + InterfaceRequest<Application>* request) {
|
| RunnerConnectionImpl* connection = new RunnerConnectionImpl;
|
| - if (!connection->WaitForApplicationRequest(request, handle.Pass())) {
|
| + if (!connection->WaitForApplicationRequest(request)) {
|
| delete connection;
|
| return nullptr;
|
| }
|
|
|