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> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/threading/thread_local.h" | 12 #include "base/threading/thread_local.h" |
13 #include "mojo/converters/network/network_type_converters.h" | 13 #include "mojo/converters/network/network_type_converters.h" |
14 #include "mojo/shell/public/cpp/application_delegate.h" | |
15 #include "mojo/shell/public/cpp/application_impl.h" | 14 #include "mojo/shell/public/cpp/application_impl.h" |
| 15 #include "mojo/shell/public/cpp/shell_client.h" |
16 #include "mojo/shell/runner/child/runner_connection.h" | 16 #include "mojo/shell/runner/child/runner_connection.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 namespace { | 19 namespace { |
20 using MojoShellConnectionPtr = | 20 using MojoShellConnectionPtr = |
21 base::ThreadLocalPointer<MojoShellConnectionImpl>; | 21 base::ThreadLocalPointer<MojoShellConnectionImpl>; |
22 | 22 |
23 // Env is thread local so that aura may be used on multiple threads. | 23 // Env is thread local so that aura may be used on multiple threads. |
24 base::LazyInstance<MojoShellConnectionPtr>::Leaky lazy_tls_ptr = | 24 base::LazyInstance<MojoShellConnectionPtr>::Leaky lazy_tls_ptr = |
25 LAZY_INSTANCE_INITIALIZER; | 25 LAZY_INSTANCE_INITIALIZER; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 new mojo::ApplicationImpl(this, std::move(application_request))); | 71 new mojo::ApplicationImpl(this, std::move(application_request))); |
72 application_impl_->WaitForInitialize(); | 72 application_impl_->WaitForInitialize(); |
73 } | 73 } |
74 | 74 |
75 void MojoShellConnectionImpl::Initialize(mojo::Shell* shell, | 75 void MojoShellConnectionImpl::Initialize(mojo::Shell* shell, |
76 const std::string& url, | 76 const std::string& url, |
77 uint32_t id) { | 77 uint32_t id) { |
78 initialized_ = true; | 78 initialized_ = true; |
79 } | 79 } |
80 | 80 |
81 bool MojoShellConnectionImpl::AcceptConnection( | 81 bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) { |
82 mojo::ApplicationConnection* connection) { | |
83 bool found = false; | 82 bool found = false; |
84 for (auto listener : listeners_) | 83 for (auto listener : listeners_) |
85 found |= listener->AcceptConnection(connection); | 84 found |= listener->AcceptConnection(connection); |
86 return found; | 85 return found; |
87 } | 86 } |
88 | 87 |
89 mojo::Shell* MojoShellConnectionImpl::GetShell() { | 88 mojo::Shell* MojoShellConnectionImpl::GetShell() { |
90 DCHECK(initialized_); | 89 DCHECK(initialized_); |
91 return application_impl_.get(); | 90 return application_impl_.get(); |
92 } | 91 } |
(...skipping 18 matching lines...) Expand all Loading... |
111 // static | 110 // static |
112 void MojoShellConnection::Destroy() { | 111 void MojoShellConnection::Destroy() { |
113 // This joins the shell controller thread. | 112 // This joins the shell controller thread. |
114 delete Get(); | 113 delete Get(); |
115 lazy_tls_ptr.Pointer()->Set(nullptr); | 114 lazy_tls_ptr.Pointer()->Set(nullptr); |
116 } | 115 } |
117 | 116 |
118 MojoShellConnection::~MojoShellConnection() {} | 117 MojoShellConnection::~MojoShellConnection() {} |
119 | 118 |
120 } // namespace content | 119 } // namespace content |
OLD | NEW |