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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 &request, std::move(handle), false /* exit_on_error */)); | 86 &request, std::move(handle), false /* exit_on_error */)); |
87 if (!runner_connection_) { | 87 if (!runner_connection_) { |
88 delete this; | 88 delete this; |
89 lazy_tls_ptr.Pointer()->Set(nullptr); | 89 lazy_tls_ptr.Pointer()->Set(nullptr); |
90 return; | 90 return; |
91 } | 91 } |
92 shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); | 92 shell_connection_.reset(new mojo::ShellConnection(this, std::move(request))); |
93 shell_connection_->WaitForInitialize(); | 93 shell_connection_->WaitForInitialize(); |
94 } | 94 } |
95 | 95 |
96 void MojoShellConnectionImpl::Initialize(mojo::Shell* shell, | 96 void MojoShellConnectionImpl::Initialize(mojo::Connector* connector, |
97 const std::string& url, | 97 const std::string& url, |
98 uint32_t id, | 98 uint32_t id, |
99 uint32_t user_id) { | 99 uint32_t user_id) { |
100 initialized_ = true; | 100 initialized_ = true; |
101 } | 101 } |
102 | 102 |
103 bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) { | 103 bool MojoShellConnectionImpl::AcceptConnection(mojo::Connection* connection) { |
104 bool found = false; | 104 bool found = false; |
105 for (auto listener : listeners_) | 105 for (auto listener : listeners_) |
106 found |= listener->AcceptConnection(connection); | 106 found |= listener->AcceptConnection(connection); |
107 return found; | 107 return found; |
108 } | 108 } |
109 | 109 |
110 mojo::Shell* MojoShellConnectionImpl::GetShell() { | 110 mojo::Connector* MojoShellConnectionImpl::GetConnector() { |
111 DCHECK(initialized_); | 111 DCHECK(initialized_); |
112 return shell_connection_.get(); | 112 return shell_connection_->connector(); |
113 } | 113 } |
114 | 114 |
115 bool MojoShellConnectionImpl::UsingExternalShell() const { | 115 bool MojoShellConnectionImpl::UsingExternalShell() const { |
116 return external_; | 116 return external_; |
117 } | 117 } |
118 | 118 |
119 void MojoShellConnectionImpl::AddListener(Listener* listener) { | 119 void MojoShellConnectionImpl::AddListener(Listener* listener) { |
120 DCHECK(std::find(listeners_.begin(), listeners_.end(), listener) == | 120 DCHECK(std::find(listeners_.begin(), listeners_.end(), listener) == |
121 listeners_.end()); | 121 listeners_.end()); |
122 listeners_.push_back(listener); | 122 listeners_.push_back(listener); |
(...skipping 13 matching lines...) Expand all Loading... |
136 // static | 136 // static |
137 void MojoShellConnection::Destroy() { | 137 void MojoShellConnection::Destroy() { |
138 // This joins the shell controller thread. | 138 // This joins the shell controller thread. |
139 delete Get(); | 139 delete Get(); |
140 lazy_tls_ptr.Pointer()->Set(nullptr); | 140 lazy_tls_ptr.Pointer()->Set(nullptr); |
141 } | 141 } |
142 | 142 |
143 MojoShellConnection::~MojoShellConnection() {} | 143 MojoShellConnection::~MojoShellConnection() {} |
144 | 144 |
145 } // namespace content | 145 } // namespace content |
OLD | NEW |