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 | |
148 void ChromotingHost::RejectAuthenticatingClient() { | 144 void ChromotingHost::RejectAuthenticatingClient() { |
149 DCHECK(authenticating_client_); | 145 DCHECK(authenticating_client_); |
150 reject_authenticating_client_ = true; | 146 reject_authenticating_client_ = true; |
151 } | 147 } |
152 | 148 |
153 void ChromotingHost::SetAuthenticatorFactory( | 149 void ChromotingHost::SetAuthenticatorFactory( |
154 scoped_ptr<protocol::AuthenticatorFactory> authenticator_factory) { | 150 scoped_ptr<protocol::AuthenticatorFactory> authenticator_factory) { |
155 DCHECK(CalledOnValidThread()); | 151 DCHECK(CalledOnValidThread()); |
156 session_manager_->set_authenticator_factory(authenticator_factory.Pass()); | 152 session_manager_->set_authenticator_factory(authenticator_factory.Pass()); |
157 } | 153 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 223 } |
228 | 224 |
229 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { | 225 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { |
230 DCHECK(CalledOnValidThread()); | 226 DCHECK(CalledOnValidThread()); |
231 | 227 |
232 // Notify observers. | 228 // Notify observers. |
233 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 229 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
234 OnClientConnected(client->client_jid())); | 230 OnClientConnected(client->client_jid())); |
235 } | 231 } |
236 | 232 |
237 void ChromotingHost::OnSessionClientCapabilities(ClientSession* client) { | |
238 DCHECK(CalledOnValidThread()); | |
239 | |
240 // Create extension sessions from each registered extension for this client. | |
241 for (HostExtensionList::iterator extension = extensions_.begin(); | |
242 extension != extensions_.end(); ++extension) { | |
243 scoped_ptr<HostExtensionSession> extension_session = | |
244 (*extension)->CreateExtensionSession(client); | |
245 if (extension_session) | |
246 client->AddExtensionSession(extension_session.Pass()); | |
247 } | |
248 } | |
249 | |
250 void ChromotingHost::OnSessionAuthenticationFailed(ClientSession* client) { | 233 void ChromotingHost::OnSessionAuthenticationFailed(ClientSession* client) { |
251 DCHECK(CalledOnValidThread()); | 234 DCHECK(CalledOnValidThread()); |
252 | 235 |
253 // Notify observers. | 236 // Notify observers. |
254 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 237 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
255 OnAccessDenied(client->client_jid())); | 238 OnAccessDenied(client->client_jid())); |
256 } | 239 } |
257 | 240 |
258 void ChromotingHost::OnSessionClosed(ClientSession* client) { | 241 void ChromotingHost::OnSessionClosed(ClientSession* client) { |
259 DCHECK(CalledOnValidThread()); | 242 DCHECK(CalledOnValidThread()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 audio_task_runner_, | 313 audio_task_runner_, |
331 input_task_runner_, | 314 input_task_runner_, |
332 video_capture_task_runner_, | 315 video_capture_task_runner_, |
333 video_encode_task_runner_, | 316 video_encode_task_runner_, |
334 network_task_runner_, | 317 network_task_runner_, |
335 ui_task_runner_, | 318 ui_task_runner_, |
336 connection.Pass(), | 319 connection.Pass(), |
337 desktop_environment_factory_, | 320 desktop_environment_factory_, |
338 max_session_duration_, | 321 max_session_duration_, |
339 pairing_registry_); | 322 pairing_registry_); |
340 | |
341 // Registers capabilities provided by host extensions. | |
342 for (HostExtensionList::iterator extension = extensions_.begin(); | |
343 extension != extensions_.end(); ++extension) { | |
344 client->AddHostCapabilities((*extension)->GetCapabilities()); | |
345 } | |
346 | |
347 clients_.push_back(client); | 323 clients_.push_back(client); |
348 } | 324 } |
349 | 325 |
350 void ChromotingHost::set_protocol_config( | 326 void ChromotingHost::set_protocol_config( |
351 scoped_ptr<protocol::CandidateSessionConfig> config) { | 327 scoped_ptr<protocol::CandidateSessionConfig> config) { |
352 DCHECK(CalledOnValidThread()); | 328 DCHECK(CalledOnValidThread()); |
353 DCHECK(config.get()); | 329 DCHECK(config.get()); |
354 DCHECK(!started_); | 330 DCHECK(!started_); |
355 protocol_config_ = config.Pass(); | 331 protocol_config_ = config.Pass(); |
356 } | 332 } |
357 | 333 |
358 void ChromotingHost::DisconnectAllClients() { | 334 void ChromotingHost::DisconnectAllClients() { |
359 DCHECK(CalledOnValidThread()); | 335 DCHECK(CalledOnValidThread()); |
360 | 336 |
361 while (!clients_.empty()) { | 337 while (!clients_.empty()) { |
362 size_t size = clients_.size(); | 338 size_t size = clients_.size(); |
363 clients_.front()->DisconnectSession(); | 339 clients_.front()->DisconnectSession(); |
364 CHECK_EQ(clients_.size(), size - 1); | 340 CHECK_EQ(clients_.size(), size - 1); |
365 } | 341 } |
366 } | 342 } |
367 | 343 |
368 } // namespace remoting | 344 } // namespace remoting |
OLD | NEW |