OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/mojo/mojo_shell_connection_impl.h" | 5 #include "content/common/mojo/mojo_shell_connection_impl.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
9 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
10 #include "base/threading/thread_local.h" | 12 #include "base/threading/thread_local.h" |
11 #include "mojo/application/public/cpp/application_delegate.h" | 13 #include "mojo/application/public/cpp/application_delegate.h" |
12 #include "mojo/application/public/cpp/application_impl.h" | 14 #include "mojo/application/public/cpp/application_impl.h" |
13 #include "mojo/converters/network/network_type_converters.h" | 15 #include "mojo/converters/network/network_type_converters.h" |
14 #include "mojo/runner/child/runner_connection.h" | 16 #include "mojo/runner/child/runner_connection.h" |
15 | 17 |
16 namespace content { | 18 namespace content { |
(...skipping 28 matching lines...) Expand all Loading... |
45 DCHECK(IsRunningInMojoShell()); | 47 DCHECK(IsRunningInMojoShell()); |
46 if (initialized_) | 48 if (initialized_) |
47 return; | 49 return; |
48 WaitForShell(mojo::ScopedMessagePipeHandle()); | 50 WaitForShell(mojo::ScopedMessagePipeHandle()); |
49 } | 51 } |
50 | 52 |
51 void MojoShellConnectionImpl::BindToMessagePipe( | 53 void MojoShellConnectionImpl::BindToMessagePipe( |
52 mojo::ScopedMessagePipeHandle handle) { | 54 mojo::ScopedMessagePipeHandle handle) { |
53 if (initialized_) | 55 if (initialized_) |
54 return; | 56 return; |
55 WaitForShell(handle.Pass()); | 57 WaitForShell(std::move(handle)); |
56 } | 58 } |
57 | 59 |
58 MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {} | 60 MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {} |
59 MojoShellConnectionImpl::~MojoShellConnectionImpl() { | 61 MojoShellConnectionImpl::~MojoShellConnectionImpl() { |
60 STLDeleteElements(&listeners_); | 62 STLDeleteElements(&listeners_); |
61 } | 63 } |
62 | 64 |
63 void MojoShellConnectionImpl::WaitForShell( | 65 void MojoShellConnectionImpl::WaitForShell( |
64 mojo::ScopedMessagePipeHandle handle) { | 66 mojo::ScopedMessagePipeHandle handle) { |
65 mojo::InterfaceRequest<mojo::Application> application_request; | 67 mojo::InterfaceRequest<mojo::Application> application_request; |
66 runner_connection_.reset(mojo::runner::RunnerConnection::ConnectToRunner( | 68 runner_connection_.reset(mojo::runner::RunnerConnection::ConnectToRunner( |
67 &application_request, handle.Pass())); | 69 &application_request, std::move(handle))); |
68 application_impl_.reset(new mojo::ApplicationImpl( | 70 application_impl_.reset( |
69 this, application_request.Pass())); | 71 new mojo::ApplicationImpl(this, std::move(application_request))); |
70 application_impl_->WaitForInitialize(); | 72 application_impl_->WaitForInitialize(); |
71 } | 73 } |
72 | 74 |
73 void MojoShellConnectionImpl::Initialize(mojo::ApplicationImpl* application) { | 75 void MojoShellConnectionImpl::Initialize(mojo::ApplicationImpl* application) { |
74 initialized_ = true; | 76 initialized_ = true; |
75 } | 77 } |
76 | 78 |
77 bool MojoShellConnectionImpl::ConfigureIncomingConnection( | 79 bool MojoShellConnectionImpl::ConfigureIncomingConnection( |
78 mojo::ApplicationConnection* connection) { | 80 mojo::ApplicationConnection* connection) { |
79 bool found = false; | 81 bool found = false; |
(...skipping 27 matching lines...) Expand all Loading... |
107 // static | 109 // static |
108 void MojoShellConnection::Destroy() { | 110 void MojoShellConnection::Destroy() { |
109 // This joins the shell controller thread. | 111 // This joins the shell controller thread. |
110 delete Get(); | 112 delete Get(); |
111 lazy_tls_ptr.Pointer()->Set(nullptr); | 113 lazy_tls_ptr.Pointer()->Set(nullptr); |
112 } | 114 } |
113 | 115 |
114 MojoShellConnection::~MojoShellConnection() {} | 116 MojoShellConnection::~MojoShellConnection() {} |
115 | 117 |
116 } // namespace content | 118 } // namespace content |
OLD | NEW |