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" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 void MojoShellConnectionImpl::WaitForShell( | 65 void MojoShellConnectionImpl::WaitForShell( |
66 mojo::ScopedMessagePipeHandle handle) { | 66 mojo::ScopedMessagePipeHandle handle) { |
67 mojo::shell::mojom::ShellClientRequest request; | 67 mojo::shell::mojom::ShellClientRequest request; |
68 runner_connection_.reset(mojo::shell::RunnerConnection::ConnectToRunner( | 68 runner_connection_.reset(mojo::shell::RunnerConnection::ConnectToRunner( |
69 &request, std::move(handle))); | 69 &request, std::move(handle))); |
70 shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); | 70 shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); |
71 shell_connection_->WaitForInitialize(); | 71 shell_connection_->WaitForInitialize(); |
72 } | 72 } |
73 | 73 |
74 void MojoShellConnectionImpl::Initialize(mojo::Shell* shell, | 74 void MojoShellConnectionImpl::Initialize(mojo::Connector* connector, |
75 const std::string& url, | 75 const std::string& url, |
76 uint32_t id, | 76 uint32_t id, |
77 uint32_t user_id) { | 77 uint32_t user_id) { |
78 initialized_ = true; | 78 initialized_ = true; |
79 } | 79 } |
80 | 80 |
81 bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) { | 81 bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) { |
82 bool found = false; | 82 bool found = false; |
83 for (auto listener : listeners_) | 83 for (auto listener : listeners_) |
84 found |= listener->AcceptConnection(connection); | 84 found |= listener->AcceptConnection(connection); |
85 return found; | 85 return found; |
86 } | 86 } |
87 | 87 |
88 mojo::Shell* MojoShellConnectionImpl::GetShell() { | 88 mojo::Connector* MojoShellConnectionImpl::GetConnector() { |
89 DCHECK(initialized_); | 89 DCHECK(initialized_); |
90 return shell_connection_.get(); | 90 return shell_connection_->connector(); |
91 } | 91 } |
92 | 92 |
93 bool MojoShellConnectionImpl::UsingExternalShell() const { | 93 bool MojoShellConnectionImpl::UsingExternalShell() const { |
94 return true; | 94 return true; |
95 } | 95 } |
96 | 96 |
97 void MojoShellConnectionImpl::AddListener(Listener* listener) { | 97 void MojoShellConnectionImpl::AddListener(Listener* listener) { |
98 DCHECK(std::find(listeners_.begin(), listeners_.end(), listener) == | 98 DCHECK(std::find(listeners_.begin(), listeners_.end(), listener) == |
99 listeners_.end()); | 99 listeners_.end()); |
100 listeners_.push_back(listener); | 100 listeners_.push_back(listener); |
(...skipping 13 matching lines...) Expand all Loading... |
114 // static | 114 // static |
115 void MojoShellConnection::Destroy() { | 115 void MojoShellConnection::Destroy() { |
116 // This joins the shell controller thread. | 116 // This joins the shell controller thread. |
117 delete Get(); | 117 delete Get(); |
118 lazy_tls_ptr.Pointer()->Set(nullptr); | 118 lazy_tls_ptr.Pointer()->Set(nullptr); |
119 } | 119 } |
120 | 120 |
121 MojoShellConnection::~MojoShellConnection() {} | 121 MojoShellConnection::~MojoShellConnection() {} |
122 | 122 |
123 } // namespace content | 123 } // namespace content |
OLD | NEW |