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

Unified Diff: remoting/host/ipc_desktop_environment.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/ipc_desktop_environment.h ('k') | remoting/host/ipc_desktop_environment_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/ipc_desktop_environment.cc
diff --git a/remoting/host/ipc_desktop_environment.cc b/remoting/host/ipc_desktop_environment.cc
index 699f06ad62f5aae31a4f88dcb7ec2143a4a84f47..b15ce633b41fdaa064ba0e6a174c0d63c676324e 100644
--- a/remoting/host/ipc_desktop_environment.cc
+++ b/remoting/host/ipc_desktop_environment.cc
@@ -13,6 +13,8 @@
#include "ipc/ipc_message_macros.h"
#include "remoting/capturer/capture_data.h"
#include "remoting/capturer/video_frame_capturer.h"
+#include "remoting/codec/audio_encoder.h"
+#include "remoting/codec/video_encoder.h"
#include "remoting/host/audio_capturer.h"
#include "remoting/host/chromoting_messages.h"
#include "remoting/host/client_session.h"
@@ -20,7 +22,6 @@
#include "remoting/host/desktop_session_proxy.h"
#include "remoting/host/event_executor.h"
#include "remoting/host/ipc_audio_capturer.h"
-#include "remoting/host/ipc_event_executor.h"
#include "remoting/host/ipc_video_frame_capturer.h"
#if defined(OS_WIN)
@@ -30,47 +31,116 @@
namespace remoting {
IpcDesktopEnvironment::IpcDesktopEnvironment(
- scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
- DesktopSessionConnector* desktop_session_connector,
- scoped_refptr<DesktopSessionProxy> desktop_session_proxy)
- : DesktopEnvironment(
- scoped_ptr<AudioCapturer>(
- new IpcAudioCapturer(desktop_session_proxy)),
- scoped_ptr<EventExecutor>(
- new IpcEventExecutor(desktop_session_proxy)),
- scoped_ptr<VideoFrameCapturer>(
- new IpcVideoFrameCapturer(desktop_session_proxy))),
- network_task_runner_(network_task_runner),
+ scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
+ const std::string& client_jid,
+ const base::Closure& disconnect_callback,
+ base::WeakPtr<DesktopSessionConnector> desktop_session_connector)
+ : caller_task_runner_(caller_task_runner),
+ connected_(false),
desktop_session_connector_(desktop_session_connector),
- desktop_session_proxy_(desktop_session_proxy),
- connected_(false) {
+ desktop_session_proxy_(new DesktopSessionProxy(caller_task_runner,
+ client_jid,
+ disconnect_callback)) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
}
IpcDesktopEnvironment::~IpcDesktopEnvironment() {
- if (connected_) {
- connected_ = false;
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ if (connected_ && desktop_session_connector_)
desktop_session_connector_->DisconnectTerminal(desktop_session_proxy_);
- }
+
+ connected_ = false;
+ desktop_session_proxy_->Stop();
}
-void IpcDesktopEnvironment::Start(
- scoped_ptr<protocol::ClipboardStub> client_clipboard,
- const std::string& client_jid,
- const base::Closure& disconnect_callback) {
- DCHECK(network_task_runner_->BelongsToCurrentThread());
- DCHECK(!connected_);
+void IpcDesktopEnvironment::InjectClipboardEvent(
+ const protocol::ClipboardEvent& event) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
- desktop_session_proxy_->Initialize(client_jid, disconnect_callback);
+ desktop_session_proxy_->InjectClipboardEvent(event);
+}
- // Register the proxy to receive AttachToDesktop() and DetachFromDesktop()
- // notifications.
- connected_ = true;
- desktop_session_connector_->ConnectTerminal(desktop_session_proxy_);
+void IpcDesktopEnvironment::InjectKeyEvent(const protocol::KeyEvent& event) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ desktop_session_proxy_->InjectKeyEvent(event);
+}
+
+void IpcDesktopEnvironment::InjectMouseEvent(
+ const protocol::MouseEvent& event) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ desktop_session_proxy_->InjectMouseEvent(event);
+}
+
+void IpcDesktopEnvironment::StartAudio(
+ scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
+ scoped_ptr<AudioEncoder> audio_encoder,
+ protocol::AudioStub* audio_stub) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ RegisterDesktopSessionProxy();
+ desktop_session_proxy_->StartAudio(audio_task_runner, audio_encoder.Pass(),
+ audio_stub);
+}
+
+void IpcDesktopEnvironment::PauseAudio(bool pause) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ desktop_session_proxy_->PauseAudio(pause);
+}
- DesktopEnvironment::Start(client_clipboard.Pass(), client_jid,
- disconnect_callback);
+void IpcDesktopEnvironment::StartInput(
+ scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
+ protocol::ClipboardStub* clipboard_stub) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ RegisterDesktopSessionProxy();
+ desktop_session_proxy_->StartInput(input_task_runner, ui_task_runner,
+ clipboard_stub);
+}
+
+void IpcDesktopEnvironment::StartVideo(
+ scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
+ scoped_ptr<VideoEncoder> video_encoder,
+ protocol::CursorShapeStub* cursor_shape_stub,
+ protocol::VideoStub* video_stub) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ RegisterDesktopSessionProxy();
+ desktop_session_proxy_->StartVideo(capture_task_runner,
+ encode_task_runner,
+ video_encoder.Pass(),
+ cursor_shape_stub,
+ video_stub);
+}
+
+SkISize IpcDesktopEnvironment::GetScreenSize() const {
+ return desktop_session_proxy_->GetScreenSize();
+}
+
+void IpcDesktopEnvironment::PauseVideo(bool pause) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ desktop_session_proxy_->PauseVideo(pause);
+}
+
+void IpcDesktopEnvironment::UpdateSequenceNumber(int64 sequence_number) {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ desktop_session_proxy_->UpdateSequenceNumber(sequence_number);
+}
+
+void IpcDesktopEnvironment::RegisterDesktopSessionProxy() {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ if (!connected_) {
+ connected_ = true;
+ desktop_session_connector_->ConnectTerminal(desktop_session_proxy_);
+ }
}
} // namespace remoting
« no previous file with comments | « remoting/host/ipc_desktop_environment.h ('k') | remoting/host/ipc_desktop_environment_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698