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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/stl_util.h" | |
9 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
10 #include "mojo/application/public/cpp/application_delegate.h" | 11 #include "mojo/application/public/cpp/application_delegate.h" |
11 #include "mojo/application/public/cpp/application_impl.h" | 12 #include "mojo/application/public/cpp/application_impl.h" |
12 #include "mojo/converters/network/network_type_converters.h" | 13 #include "mojo/converters/network/network_type_converters.h" |
13 #include "mojo/runner/child/runner_connection.h" | 14 #include "mojo/runner/child/runner_connection.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 namespace { | 17 namespace { |
17 using MojoShellConnectionPtr = | 18 using MojoShellConnectionPtr = |
18 base::ThreadLocalPointer<MojoShellConnectionImpl>; | 19 base::ThreadLocalPointer<MojoShellConnectionImpl>; |
(...skipping 18 matching lines...) Expand all Loading... | |
37 // static | 38 // static |
38 void MojoShellConnectionImpl::CreateWithMessagePipe( | 39 void MojoShellConnectionImpl::CreateWithMessagePipe( |
39 mojo::ScopedMessagePipeHandle handle) { | 40 mojo::ScopedMessagePipeHandle handle) { |
40 DCHECK(!lazy_tls_ptr.Pointer()->Get()); | 41 DCHECK(!lazy_tls_ptr.Pointer()->Get()); |
41 MojoShellConnectionImpl* connection = new MojoShellConnectionImpl; | 42 MojoShellConnectionImpl* connection = new MojoShellConnectionImpl; |
42 lazy_tls_ptr.Pointer()->Set(connection); | 43 lazy_tls_ptr.Pointer()->Set(connection); |
43 connection->WaitForShell(handle.Pass()); | 44 connection->WaitForShell(handle.Pass()); |
44 } | 45 } |
45 | 46 |
46 MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {} | 47 MojoShellConnectionImpl::MojoShellConnectionImpl() : initialized_(false) {} |
47 MojoShellConnectionImpl::~MojoShellConnectionImpl() {} | 48 MojoShellConnectionImpl::~MojoShellConnectionImpl() { |
49 STLDeleteElements(&listeners_); | |
Ben Goodger (Google)
2015/11/24 15:30:05
document in the /public/ header that this object t
Fady Samuel
2015/11/24 17:06:36
Done.
| |
50 } | |
48 | 51 |
49 void MojoShellConnectionImpl::WaitForShell( | 52 void MojoShellConnectionImpl::WaitForShell( |
50 mojo::ScopedMessagePipeHandle handle) { | 53 mojo::ScopedMessagePipeHandle handle) { |
51 mojo::InterfaceRequest<mojo::Application> application_request; | 54 mojo::InterfaceRequest<mojo::Application> application_request; |
52 runner_connection_.reset(mojo::runner::RunnerConnection::ConnectToRunner( | 55 runner_connection_.reset(mojo::runner::RunnerConnection::ConnectToRunner( |
53 &application_request, handle.Pass())); | 56 &application_request, handle.Pass())); |
54 application_impl_.reset(new mojo::ApplicationImpl( | 57 application_impl_.reset(new mojo::ApplicationImpl( |
55 this, application_request.Pass())); | 58 this, application_request.Pass())); |
56 application_impl_->WaitForInitialize(); | 59 application_impl_->WaitForInitialize(); |
57 } | 60 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 // static | 96 // static |
94 void MojoShellConnection::Destroy() { | 97 void MojoShellConnection::Destroy() { |
95 // This joins the shell controller thread. | 98 // This joins the shell controller thread. |
96 delete Get(); | 99 delete Get(); |
97 lazy_tls_ptr.Pointer()->Set(nullptr); | 100 lazy_tls_ptr.Pointer()->Set(nullptr); |
98 } | 101 } |
99 | 102 |
100 MojoShellConnection::~MojoShellConnection() {} | 103 MojoShellConnection::~MojoShellConnection() {} |
101 | 104 |
102 } // namespace content | 105 } // namespace content |
OLD | NEW |