OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) { | 134 void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) { |
135 DCHECK(CalledOnValidThread()); | 135 DCHECK(CalledOnValidThread()); |
136 status_observers_.AddObserver(observer); | 136 status_observers_.AddObserver(observer); |
137 } | 137 } |
138 | 138 |
139 void ChromotingHost::RemoveStatusObserver(HostStatusObserver* observer) { | 139 void ChromotingHost::RemoveStatusObserver(HostStatusObserver* observer) { |
140 DCHECK(CalledOnValidThread()); | 140 DCHECK(CalledOnValidThread()); |
141 status_observers_.RemoveObserver(observer); | 141 status_observers_.RemoveObserver(observer); |
142 } | 142 } |
143 | 143 |
144 void ChromotingHost::AddExtension(scoped_ptr<HostExtension> extension) { | |
145 extensions_.push_back(extension.release()); | |
146 } | |
147 | |
144 void ChromotingHost::RejectAuthenticatingClient() { | 148 void ChromotingHost::RejectAuthenticatingClient() { |
145 DCHECK(authenticating_client_); | 149 DCHECK(authenticating_client_); |
146 reject_authenticating_client_ = true; | 150 reject_authenticating_client_ = true; |
147 } | 151 } |
148 | 152 |
149 void ChromotingHost::SetAuthenticatorFactory( | 153 void ChromotingHost::SetAuthenticatorFactory( |
150 scoped_ptr<protocol::AuthenticatorFactory> authenticator_factory) { | 154 scoped_ptr<protocol::AuthenticatorFactory> authenticator_factory) { |
151 DCHECK(CalledOnValidThread()); | 155 DCHECK(CalledOnValidThread()); |
152 session_manager_->set_authenticator_factory(authenticator_factory.Pass()); | 156 session_manager_->set_authenticator_factory(authenticator_factory.Pass()); |
153 } | 157 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 ClientList::iterator it = clients_.begin(); | 206 ClientList::iterator it = clients_.begin(); |
203 while (it != clients_.end()) { | 207 while (it != clients_.end()) { |
204 ClientSession* other_client = *it++; | 208 ClientSession* other_client = *it++; |
205 if (other_client != client) | 209 if (other_client != client) |
206 other_client->DisconnectSession(); | 210 other_client->DisconnectSession(); |
207 } | 211 } |
208 | 212 |
209 // Disconnects above must have destroyed all other clients. | 213 // Disconnects above must have destroyed all other clients. |
210 DCHECK_EQ(clients_.size(), 1U); | 214 DCHECK_EQ(clients_.size(), 1U); |
211 | 215 |
216 // Registers capabilities provided by host extensions. | |
217 for (HostExtensionList::iterator extension = extensions_.begin(); | |
218 extension != extensions_.end(); ++extension) { | |
219 client->AddHostCapabilities((*extension)->GetCapabilities()); | |
Wez
2014/05/28 23:03:41
Do you really need to do this here? Could it wait
Wez
2014/05/28 23:03:41
If not then it would seem cleaner to have SetHostC
dcaiafa
2014/05/29 00:03:16
We need to send the host capabilities to the clien
dcaiafa
2014/05/29 00:03:16
As you mentioned in the comment's message, AddHost
| |
220 } | |
221 | |
212 // Notify observers that there is at least one authenticated client. | 222 // Notify observers that there is at least one authenticated client. |
213 const std::string& jid = client->client_jid(); | 223 const std::string& jid = client->client_jid(); |
214 | 224 |
215 reject_authenticating_client_ = false; | 225 reject_authenticating_client_ = false; |
216 | 226 |
217 authenticating_client_ = true; | 227 authenticating_client_ = true; |
218 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 228 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
219 OnClientAuthenticated(jid)); | 229 OnClientAuthenticated(jid)); |
220 authenticating_client_ = false; | 230 authenticating_client_ = false; |
221 | 231 |
222 return !reject_authenticating_client_; | 232 return !reject_authenticating_client_; |
223 } | 233 } |
224 | 234 |
225 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { | 235 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { |
226 DCHECK(CalledOnValidThread()); | 236 DCHECK(CalledOnValidThread()); |
227 | 237 |
228 // Notify observers. | 238 // Notify observers. |
229 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 239 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
230 OnClientConnected(client->client_jid())); | 240 OnClientConnected(client->client_jid())); |
231 } | 241 } |
232 | 242 |
243 void ChromotingHost::OnClientCapabilities(ClientSession* client) { | |
244 DCHECK(CalledOnValidThread()); | |
245 | |
246 // Create extension sessions from each registered extension for this client. | |
247 for (HostExtensionList::iterator extension = extensions_.begin(); | |
248 extension != extensions_.end(); ++extension) { | |
249 scoped_ptr<HostExtensionSession> extension_session = | |
250 (*extension)->CreateExtensionSession(client); | |
251 if (extension_session) | |
252 client->AddExtensionSession(extension_session.Pass()); | |
253 } | |
254 } | |
255 | |
233 void ChromotingHost::OnSessionAuthenticationFailed(ClientSession* client) { | 256 void ChromotingHost::OnSessionAuthenticationFailed(ClientSession* client) { |
234 DCHECK(CalledOnValidThread()); | 257 DCHECK(CalledOnValidThread()); |
235 | 258 |
236 // Notify observers. | 259 // Notify observers. |
237 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 260 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
238 OnAccessDenied(client->client_jid())); | 261 OnAccessDenied(client->client_jid())); |
239 } | 262 } |
240 | 263 |
241 void ChromotingHost::OnSessionClosed(ClientSession* client) { | 264 void ChromotingHost::OnSessionClosed(ClientSession* client) { |
242 DCHECK(CalledOnValidThread()); | 265 DCHECK(CalledOnValidThread()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 DCHECK(CalledOnValidThread()); | 358 DCHECK(CalledOnValidThread()); |
336 | 359 |
337 while (!clients_.empty()) { | 360 while (!clients_.empty()) { |
338 size_t size = clients_.size(); | 361 size_t size = clients_.size(); |
339 clients_.front()->DisconnectSession(); | 362 clients_.front()->DisconnectSession(); |
340 CHECK_EQ(clients_.size(), size - 1); | 363 CHECK_EQ(clients_.size(), size - 1); |
341 } | 364 } |
342 } | 365 } |
343 | 366 |
344 } // namespace remoting | 367 } // namespace remoting |
OLD | NEW |