| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "googleurl/src/gurl.h" |
| 12 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
| 13 #include "remoting/base/encoder.h" | 14 #include "remoting/base/encoder.h" |
| 14 #include "remoting/base/encoder_row_based.h" | 15 #include "remoting/base/encoder_row_based.h" |
| 15 #include "remoting/base/encoder_vp8.h" | 16 #include "remoting/base/encoder_vp8.h" |
| 16 #include "remoting/codec/audio_encoder.h" | 17 #include "remoting/codec/audio_encoder.h" |
| 17 #include "remoting/codec/audio_encoder_verbatim.h" | 18 #include "remoting/codec/audio_encoder_verbatim.h" |
| 18 #include "remoting/host/audio_scheduler.h" | 19 #include "remoting/host/audio_scheduler.h" |
| 19 #include "remoting/host/chromoting_host_context.h" | 20 #include "remoting/host/chromoting_host_context.h" |
| 20 #include "remoting/host/desktop_environment.h" | 21 #include "remoting/host/desktop_environment.h" |
| 21 #include "remoting/host/event_executor.h" | 22 #include "remoting/host/event_executor.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 void ChromotingHost::OnSessionRouteChange( | 304 void ChromotingHost::OnSessionRouteChange( |
| 304 ClientSession* session, | 305 ClientSession* session, |
| 305 const std::string& channel_name, | 306 const std::string& channel_name, |
| 306 const protocol::TransportRoute& route) { | 307 const protocol::TransportRoute& route) { |
| 307 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 308 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 308 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 309 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
| 309 OnClientRouteChange(session->client_jid(), channel_name, | 310 OnClientRouteChange(session->client_jid(), channel_name, |
| 310 route)); | 311 route)); |
| 311 } | 312 } |
| 312 | 313 |
| 314 // SessionManager::Listener implementation. |
| 313 void ChromotingHost::OnSessionManagerReady() { | 315 void ChromotingHost::OnSessionManagerReady() { |
| 314 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 316 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 315 // Don't need to do anything here, just wait for incoming | 317 // Don't need to do anything here, just wait for incoming |
| 316 // connections. | 318 // connections. |
| 317 } | 319 } |
| 318 | 320 |
| 319 void ChromotingHost::OnIncomingSession( | 321 void ChromotingHost::OnIncomingSession( |
| 320 protocol::Session* session, | 322 protocol::Session* session, |
| 321 protocol::SessionManager::IncomingSessionResponse* response) { | 323 protocol::SessionManager::IncomingSessionResponse* response) { |
| 322 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 324 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 ClientSession* client = new ClientSession( | 359 ClientSession* client = new ClientSession( |
| 358 this, | 360 this, |
| 359 connection.Pass(), | 361 connection.Pass(), |
| 360 desktop_environment_->event_executor(), | 362 desktop_environment_->event_executor(), |
| 361 desktop_environment_->event_executor(), | 363 desktop_environment_->event_executor(), |
| 362 desktop_environment_->capturer(), | 364 desktop_environment_->capturer(), |
| 363 max_session_duration_); | 365 max_session_duration_); |
| 364 clients_.push_back(client); | 366 clients_.push_back(client); |
| 365 } | 367 } |
| 366 | 368 |
| 367 void ChromotingHost::set_protocol_config( | 369 // MouseMoveObserver interface. |
| 368 protocol::CandidateSessionConfig* config) { | |
| 369 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | |
| 370 DCHECK(config); | |
| 371 DCHECK_EQ(state_, kInitial); | |
| 372 protocol_config_.reset(config); | |
| 373 } | |
| 374 | |
| 375 void ChromotingHost::OnLocalMouseMoved(const SkIPoint& new_pos) { | 370 void ChromotingHost::OnLocalMouseMoved(const SkIPoint& new_pos) { |
| 376 if (!context_->network_task_runner()->BelongsToCurrentThread()) { | 371 if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
| 377 context_->network_task_runner()->PostTask( | 372 context_->network_task_runner()->PostTask( |
| 378 FROM_HERE, base::Bind(&ChromotingHost::OnLocalMouseMoved, | 373 FROM_HERE, base::Bind(&ChromotingHost::OnLocalMouseMoved, |
| 379 this, new_pos)); | 374 this, new_pos)); |
| 380 return; | 375 return; |
| 381 } | 376 } |
| 382 | 377 |
| 383 ClientList::iterator client; | 378 ClientList::iterator client; |
| 384 for (client = clients_.begin(); client != clients_.end(); ++client) { | 379 for (client = clients_.begin(); client != clients_.end(); ++client) { |
| 385 (*client)->LocalMouseMoved(new_pos); | 380 (*client)->LocalMouseMoved(new_pos); |
| 386 } | 381 } |
| 387 } | 382 } |
| 388 | 383 |
| 384 void ChromotingHost::set_protocol_config( |
| 385 protocol::CandidateSessionConfig* config) { |
| 386 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 387 DCHECK(config); |
| 388 DCHECK_EQ(state_, kInitial); |
| 389 protocol_config_.reset(config); |
| 390 } |
| 391 |
| 389 void ChromotingHost::PauseSession(bool pause) { | 392 void ChromotingHost::PauseSession(bool pause) { |
| 390 if (!context_->network_task_runner()->BelongsToCurrentThread()) { | 393 if (!context_->network_task_runner()->BelongsToCurrentThread()) { |
| 391 context_->network_task_runner()->PostTask( | 394 context_->network_task_runner()->PostTask( |
| 392 FROM_HERE, base::Bind(&ChromotingHost::PauseSession, this, pause)); | 395 FROM_HERE, base::Bind(&ChromotingHost::PauseSession, this, pause)); |
| 393 return; | 396 return; |
| 394 } | 397 } |
| 395 | 398 |
| 396 ClientList::iterator client; | 399 ClientList::iterator client; |
| 397 for (client = clients_.begin(); client != clients_.end(); ++client) { | 400 for (client = clients_.begin(); client != clients_.end(); ++client) { |
| 398 (*client)->SetDisableInputs(pause); | 401 (*client)->SetDisableInputs(pause); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 OnShutdown()); | 501 OnShutdown()); |
| 499 | 502 |
| 500 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); | 503 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); |
| 501 it != shutdown_tasks_.end(); ++it) { | 504 it != shutdown_tasks_.end(); ++it) { |
| 502 it->Run(); | 505 it->Run(); |
| 503 } | 506 } |
| 504 shutdown_tasks_.clear(); | 507 shutdown_tasks_.clear(); |
| 505 } | 508 } |
| 506 | 509 |
| 507 } // namespace remoting | 510 } // namespace remoting |
| OLD | NEW |