Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(912)

Unified Diff: remoting/host/client_session.cc

Issue 14520018: Create the desktop environment before any of the channel were connected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/client_session.h ('k') | remoting/host/client_session_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/client_session.cc
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index ab1ab5136cdfe1040c6251cb63f3fea33cb38985..280a3c3b71cbe1207934e377868a6dfa2eb3684c 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -124,8 +124,7 @@ void ClientSession::ControlVideo(const protocol::VideoControl& video_control) {
if (video_control.has_enable()) {
VLOG(1) << "Received VideoControl (enable="
<< video_control.enable() << ")";
- if (video_scheduler_)
- video_scheduler_->Pause(!video_control.enable());
+ video_scheduler_->Pause(!video_control.enable());
}
}
@@ -165,17 +164,19 @@ void ClientSession::SetCapabilities(
// Calculate the set of capabilities enabled by both client and host and
// pass it to the desktop environment if it is available.
- if (desktop_environment_) {
- desktop_environment_->SetCapabilities(
- IntersectCapabilities(*client_capabilities_, host_capabilities_));
- }
+ desktop_environment_->SetCapabilities(
+ IntersectCapabilities(*client_capabilities_, host_capabilities_));
}
void ClientSession::OnConnectionAuthenticated(
protocol::ConnectionToClient* connection) {
DCHECK(CalledOnValidThread());
DCHECK_EQ(connection_.get(), connection);
+ DCHECK(!audio_scheduler_);
DCHECK(!desktop_environment_);
+ DCHECK(!input_injector_);
+ DCHECK(!screen_controls_);
+ DCHECK(!video_scheduler_);
auth_input_filter_.set_enabled(true);
auth_clipboard_filter_.set_enabled(true);
@@ -190,40 +191,20 @@ void ClientSession::OnConnectionAuthenticated(
this, &ClientSession::DisconnectSession);
}
- // The session may be destroyed as the result result of this call, so it must
- // be the last in this method.
- event_handler_->OnSessionAuthenticated(this);
-}
-
-void ClientSession::OnConnectionChannelsConnected(
- protocol::ConnectionToClient* connection) {
- DCHECK(CalledOnValidThread());
- DCHECK_EQ(connection_.get(), connection);
- DCHECK(!audio_scheduler_);
- DCHECK(!input_injector_);
- DCHECK(!screen_controls_);
- DCHECK(!video_scheduler_);
+ // Disconnect the session if the connection was rejected by the host.
+ if (!event_handler_->OnSessionAuthenticated(this)) {
+ DisconnectSession();
+ return;
+ }
// Create the desktop environment.
desktop_environment_ =
desktop_environment_factory_->Create(control_factory_.GetWeakPtr());
host_capabilities_ = desktop_environment_->GetCapabilities();
- // Negotiate capabilities with the client.
- if (connection_->session()->config().SupportsCapabilities()) {
- VLOG(1) << "Host capabilities: " << host_capabilities_;
-
- protocol::Capabilities capabilities;
- capabilities.set_capabilities(host_capabilities_);
- connection_->client_stub()->SetCapabilities(capabilities);
-
- // |client_capabilities_| could have been received before all channels were
- // connected. Process them now.
- if (client_capabilities_) {
- desktop_environment_->SetCapabilities(
- IntersectCapabilities(*client_capabilities_, host_capabilities_));
- }
- } else {
+ // Ignore protocol::Capabilities messages from the client if it does not
+ // support any capabilities.
+ if (!connection_->session()->config().SupportsCapabilities()) {
VLOG(1) << "The client does not support any capabilities.";
client_capabilities_ = make_scoped_ptr(new std::string());
@@ -233,22 +214,19 @@ void ClientSession::OnConnectionChannelsConnected(
// Create the object that controls the screen resolution.
screen_controls_ = desktop_environment_->CreateScreenControls();
- // Create and start the event executor.
+ // Create the event executor.
input_injector_ = desktop_environment_->CreateInputInjector();
- input_injector_->Start(CreateClipboardProxy());
// Connect the host clipboard and input stubs.
host_input_filter_.set_input_stub(input_injector_.get());
clipboard_echo_filter_.set_host_stub(input_injector_.get());
- SetDisableInputs(false);
-
// Create a VideoEncoder based on the session's video channel configuration.
scoped_ptr<VideoEncoder> video_encoder =
CreateVideoEncoder(connection_->session()->config());
// Create a VideoScheduler to pump frames from the capturer to the client.
- video_scheduler_ = VideoScheduler::Create(
+ video_scheduler_ = new VideoScheduler(
video_capture_task_runner_,
video_encode_task_runner_,
network_task_runner_,
@@ -261,13 +239,39 @@ void ClientSession::OnConnectionChannelsConnected(
if (connection_->session()->config().is_audio_enabled()) {
scoped_ptr<AudioEncoder> audio_encoder =
CreateAudioEncoder(connection_->session()->config());
- audio_scheduler_ = AudioScheduler::Create(
+ audio_scheduler_ = new AudioScheduler(
audio_task_runner_,
network_task_runner_,
desktop_environment_->CreateAudioCapturer(),
audio_encoder.Pass(),
connection_->audio_stub());
}
+}
+
+void ClientSession::OnConnectionChannelsConnected(
+ protocol::ConnectionToClient* connection) {
+ DCHECK(CalledOnValidThread());
+ DCHECK_EQ(connection_.get(), connection);
+
+ // Negotiate capabilities with the client.
+ if (connection_->session()->config().SupportsCapabilities()) {
+ VLOG(1) << "Host capabilities: " << host_capabilities_;
+
+ protocol::Capabilities capabilities;
+ capabilities.set_capabilities(host_capabilities_);
+ connection_->client_stub()->SetCapabilities(capabilities);
+ }
+
+ // Start the event executor.
+ input_injector_->Start(CreateClipboardProxy());
+ SetDisableInputs(false);
+
+ // Start capturing the screen.
+ video_scheduler_->Start();
+
+ // Start recording audio.
+ if (connection_->session()->config().is_audio_enabled())
+ audio_scheduler_->Start();
// Notify the event handler that all our channels are now connected.
event_handler_->OnSessionChannelsConnected(this);
« no previous file with comments | « remoting/host/client_session.h ('k') | remoting/host/client_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698