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

Unified Diff: remoting/host/client_session.cc

Issue 11761019: Tiny little refactoring of DesktopEnvironment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 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 f1722595d447a0523dd812829ad83c2668e1a8b3..c43747248cfc1ed748961235e1ae5f9b3eb01b98 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -15,49 +15,50 @@
#include "remoting/codec/video_encoder.h"
#include "remoting/codec/video_encoder_verbatim.h"
#include "remoting/codec/video_encoder_vp8.h"
-#include "remoting/host/audio_scheduler.h"
#include "remoting/host/desktop_environment.h"
#include "remoting/host/desktop_environment_factory.h"
#include "remoting/host/event_executor.h"
-#include "remoting/host/video_scheduler.h"
#include "remoting/proto/control.pb.h"
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/client_stub.h"
-#include "remoting/protocol/clipboard_thread_proxy.h"
namespace remoting {
ClientSession::ClientSession(
EventHandler* event_handler,
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
scoped_ptr<protocol::ConnectionToClient> connection,
DesktopEnvironmentFactory* desktop_environment_factory,
const base::TimeDelta& max_duration)
: event_handler_(event_handler),
connection_(connection.Pass()),
connection_factory_(connection_.get()),
- desktop_environment_(desktop_environment_factory->Create()),
client_jid_(connection_->session()->jid()),
- host_clipboard_stub_(desktop_environment_->event_executor()),
- host_input_stub_(desktop_environment_->event_executor()),
+ desktop_environment_(desktop_environment_factory->Create(
+ client_jid_,
+ base::Bind(&protocol::ConnectionToClient::Disconnect,
+ connection_factory_.GetWeakPtr()))),
+ host_clipboard_stub_(desktop_environment_.get()),
+ host_input_stub_(desktop_environment_.get()),
input_tracker_(host_input_stub_),
remote_input_filter_(&input_tracker_),
- mouse_clamping_filter_(desktop_environment_->video_capturer(),
- &remote_input_filter_),
+ mouse_clamping_filter_(desktop_environment_.get(), &remote_input_filter_),
disable_input_filter_(&mouse_clamping_filter_),
disable_clipboard_filter_(clipboard_echo_filter_.host_filter()),
auth_input_filter_(&disable_input_filter_),
auth_clipboard_filter_(&disable_clipboard_filter_),
- client_clipboard_factory_(clipboard_echo_filter_.client_filter()),
max_duration_(max_duration),
audio_task_runner_(audio_task_runner),
+ input_task_runner_(input_task_runner),
video_capture_task_runner_(video_capture_task_runner),
video_encode_task_runner_(video_encode_task_runner),
network_task_runner_(network_task_runner),
- active_recorders_(0) {
+ ui_task_runner_(ui_task_runner) {
connection_->SetEventHandler(this);
// TODO(sergeyu): Currently ConnectionToClient expects stubs to be
@@ -87,9 +88,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_.get()) {
- video_scheduler_->Pause(!video_control.enable());
- }
+ desktop_environment()->PauseVideo(!video_control.enable());
}
}
@@ -97,9 +96,7 @@ void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) {
if (audio_control.has_enable()) {
VLOG(1) << "Received AudioControl (enable="
<< audio_control.enable() << ")";
- if (audio_scheduler_.get()) {
- audio_scheduler_->SetEnabled(audio_control.enable());
- }
+ desktop_environment()->PauseAudio(!audio_control.enable());
}
}
@@ -130,38 +127,27 @@ void ClientSession::OnConnectionChannelsConnected(
SetDisableInputs(false);
// Let the desktop environment notify us of local clipboard changes.
- desktop_environment_->Start(
- CreateClipboardProxy(),
- client_jid(),
- base::Bind(&protocol::ConnectionToClient::Disconnect,
- connection_factory_.GetWeakPtr()));
+ desktop_environment()->StartInput(input_task_runner_, ui_task_runner_,
+ clipboard_echo_filter_.client_filter());
// 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_capture_task_runner_,
- video_encode_task_runner_,
- network_task_runner_,
- desktop_environment_->video_capturer(),
- video_encoder.Pass(),
- connection_->client_stub(),
- connection_->video_stub());
- ++active_recorders_;
+ desktop_environment()->StartVideo(video_capture_task_runner_,
+ video_encode_task_runner_,
+ video_encoder.Pass(),
+ connection_->client_stub(),
+ connection_->video_stub());
// Create an AudioScheduler if audio is enabled, to pump audio samples.
if (connection_->session()->config().is_audio_enabled()) {
scoped_ptr<AudioEncoder> audio_encoder =
CreateAudioEncoder(connection_->session()->config());
- audio_scheduler_ = AudioScheduler::Create(
- audio_task_runner_,
- network_task_runner_,
- desktop_environment_->audio_capturer(),
- audio_encoder.Pass(),
- connection_->audio_stub());
- ++active_recorders_;
+ desktop_environment()->StartAudio(audio_task_runner_,
+ audio_encoder.Pass(),
+ connection_->audio_stub());
}
// Notify the event handler that all our channels are now connected.
@@ -192,15 +178,7 @@ void ClientSession::OnConnectionClosed(
// Stop components access the client, audio or video stubs, which are no
// longer valid once ConnectionToClient calls OnConnectionClosed().
- if (audio_scheduler_.get()) {
- audio_scheduler_->Stop(base::Bind(&ClientSession::OnRecorderStopped, this));
- audio_scheduler_ = NULL;
- }
- if (video_scheduler_.get()) {
- video_scheduler_->Stop(base::Bind(&ClientSession::OnRecorderStopped, this));
- video_scheduler_ = NULL;
- }
- client_clipboard_factory_.InvalidateWeakPtrs();
+ desktop_environment_.reset();
// Notify the ChromotingHost that this client is disconnected.
// TODO(sergeyu): Log failure reason?
@@ -212,8 +190,7 @@ void ClientSession::OnSequenceNumberUpdated(
DCHECK(CalledOnValidThread());
DCHECK_EQ(connection_.get(), connection);
- if (video_scheduler_.get())
- video_scheduler_->UpdateSequenceNumber(sequence_number);
+ desktop_environment()->UpdateSequenceNumber(sequence_number);
event_handler_->OnSessionSequenceNumber(this, sequence_number);
}
@@ -238,21 +215,11 @@ void ClientSession::Disconnect() {
connection_->Disconnect();
}
-void ClientSession::Stop(const base::Closure& stopped_task) {
+void ClientSession::Stop() {
DCHECK(CalledOnValidThread());
- DCHECK(stopped_task_.is_null());
- DCHECK(!stopped_task.is_null());
- DCHECK(audio_scheduler_.get() == NULL);
- DCHECK(video_scheduler_.get() == NULL);
-
- stopped_task_ = stopped_task;
-
- if (active_recorders_ == 0) {
- // |stopped_task_| may tear down the signalling layer, so tear-down
- // |connection_| before invoking it.
- connection_.reset();
- stopped_task_.Run();
- }
+ DCHECK(!desktop_environment_);
+
+ connection_.reset();
}
void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) {
@@ -271,37 +238,7 @@ void ClientSession::SetDisableInputs(bool disable_inputs) {
}
ClientSession::~ClientSession() {
- DCHECK_EQ(active_recorders_, 0);
- DCHECK(audio_scheduler_.get() == NULL);
- DCHECK(video_scheduler_.get() == NULL);
-}
-
-scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() {
- DCHECK(CalledOnValidThread());
-
- return scoped_ptr<protocol::ClipboardStub>(
- new protocol::ClipboardThreadProxy(
- client_clipboard_factory_.GetWeakPtr(),
- base::MessageLoopProxy::current()));
-}
-
-void ClientSession::OnRecorderStopped() {
- if (!network_task_runner_->BelongsToCurrentThread()) {
- network_task_runner_->PostTask(
- FROM_HERE, base::Bind(&ClientSession::OnRecorderStopped, this));
- return;
- }
-
- --active_recorders_;
- DCHECK_GE(active_recorders_, 0);
-
- DCHECK(!stopped_task_.is_null());
- if (active_recorders_ == 0) {
- // |stopped_task_| may result in the signalling layer being torn down, so
- // tear down the ConnectionToClient first.
- connection_.reset();
- stopped_task_.Run();
- }
+ DCHECK(!desktop_environment_);
}
// TODO(sergeyu): Move this to SessionManager?
« 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