Chromium Code Reviews| Index: content/common/mojo/mojo_shell_connection_impl.cc |
| diff --git a/content/common/mojo/mojo_shell_connection_impl.cc b/content/common/mojo/mojo_shell_connection_impl.cc |
| index 839e206abcf42ab7aac256c581a94c2fcdfed34d..ea12a4d49a8bba185565deaa030e418fa50f0250 100644 |
| --- a/content/common/mojo/mojo_shell_connection_impl.cc |
| +++ b/content/common/mojo/mojo_shell_connection_impl.cc |
| @@ -48,9 +48,8 @@ void MojoShellConnectionImpl::Create( |
| new MojoShellConnectionImpl(false /* external */); |
| lazy_tls_ptr.Pointer()->Set(connection); |
| - connection->shell_connection_.reset( |
| - new mojo::ShellConnection(connection, std::move(request))); |
| - connection->shell_connection_->WaitForInitialize(); |
| + connection->shell_connection_.reset(new mojo::ShellConnection(connection)); |
| + connection->shell_connection_->BindToRequest(std::move(request)); |
|
Ben Goodger (Google)
2016/03/13 04:16:24
How is this different than just passing request th
Ken Rockot(use gerrit already)
2016/03/13 16:14:25
Oops, it's not. Fixed
|
| } |
| // static |
| @@ -58,46 +57,30 @@ MojoShellConnectionImpl* MojoShellConnectionImpl::Get() { |
| return static_cast<MojoShellConnectionImpl*>(MojoShellConnection::Get()); |
| } |
| -void MojoShellConnectionImpl::BindToCommandLinePlatformChannel() { |
| - DCHECK(IsRunningInMojoShell()); |
| - if (initialized_) |
| - return; |
| - WaitForShell(mojo::ScopedMessagePipeHandle()); |
| -} |
| +void MojoShellConnectionImpl::Connect( |
| + mojo::shell::mojom::ShellClientFactoryRequest request) { |
| + DCHECK(IsRunningInMojoShell() || request.is_pending()); |
| + DCHECK(!shell_connection_); |
| -void MojoShellConnectionImpl::BindToMessagePipe( |
| - mojo::ScopedMessagePipeHandle handle) { |
| - if (initialized_) |
| - return; |
| - WaitForShell(std::move(handle)); |
| + shell_connection_.reset(new mojo::ShellConnection(this)); |
| + runner_connection_ = mojo::shell::RunnerConnection::Create( |
| + shell_connection_.get(), std::move(request), false /* exit_on_error */); |
| + if (!runner_connection_) { |
| + delete this; |
| + lazy_tls_ptr.Pointer()->Set(nullptr); |
| + } |
| } |
| MojoShellConnectionImpl::MojoShellConnectionImpl(bool external) : |
| - external_(external), initialized_(false) {} |
| + external_(external) {} |
| MojoShellConnectionImpl::~MojoShellConnectionImpl() { |
| STLDeleteElements(&listeners_); |
| } |
| -void MojoShellConnectionImpl::WaitForShell( |
| - mojo::ScopedMessagePipeHandle handle) { |
| - mojo::shell::mojom::ShellClientRequest request; |
| - runner_connection_.reset(mojo::shell::RunnerConnection::ConnectToRunner( |
| - &request, std::move(handle), false /* exit_on_error */)); |
| - if (!runner_connection_) { |
| - DLOG(ERROR) << "Unable to connect to the Mojo shell."; |
| - delete this; |
| - lazy_tls_ptr.Pointer()->Set(nullptr); |
| - return; |
| - } |
| - shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); |
| - shell_connection_->WaitForInitialize(); |
| -} |
| - |
| void MojoShellConnectionImpl::Initialize(mojo::Connector* connector, |
| const mojo::Identity& identity, |
| uint32_t id) { |
| - initialized_ = true; |
| } |
| bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) { |
| @@ -108,7 +91,7 @@ bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) { |
| } |
| mojo::Connector* MojoShellConnectionImpl::GetConnector() { |
| - DCHECK(initialized_); |
| + DCHECK(shell_connection_); |
| return shell_connection_->connector(); |
| } |