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

Side by Side 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, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ipc_desktop_environment.h" 5 #include "remoting/host/ipc_desktop_environment.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "ipc/ipc_channel_proxy.h" 12 #include "ipc/ipc_channel_proxy.h"
13 #include "ipc/ipc_message_macros.h" 13 #include "ipc/ipc_message_macros.h"
14 #include "remoting/capturer/capture_data.h" 14 #include "remoting/capturer/capture_data.h"
15 #include "remoting/capturer/video_frame_capturer.h" 15 #include "remoting/capturer/video_frame_capturer.h"
16 #include "remoting/codec/audio_encoder.h"
17 #include "remoting/codec/video_encoder.h"
16 #include "remoting/host/audio_capturer.h" 18 #include "remoting/host/audio_capturer.h"
17 #include "remoting/host/chromoting_messages.h" 19 #include "remoting/host/chromoting_messages.h"
18 #include "remoting/host/client_session.h" 20 #include "remoting/host/client_session.h"
19 #include "remoting/host/desktop_session_connector.h" 21 #include "remoting/host/desktop_session_connector.h"
20 #include "remoting/host/desktop_session_proxy.h" 22 #include "remoting/host/desktop_session_proxy.h"
21 #include "remoting/host/event_executor.h" 23 #include "remoting/host/event_executor.h"
22 #include "remoting/host/ipc_audio_capturer.h" 24 #include "remoting/host/ipc_audio_capturer.h"
23 #include "remoting/host/ipc_event_executor.h"
24 #include "remoting/host/ipc_video_frame_capturer.h" 25 #include "remoting/host/ipc_video_frame_capturer.h"
25 26
26 #if defined(OS_WIN) 27 #if defined(OS_WIN)
27 #include "base/win/scoped_handle.h" 28 #include "base/win/scoped_handle.h"
28 #endif // defined(OS_WIN) 29 #endif // defined(OS_WIN)
29 30
30 namespace remoting { 31 namespace remoting {
31 32
32 IpcDesktopEnvironment::IpcDesktopEnvironment( 33 IpcDesktopEnvironment::IpcDesktopEnvironment(
33 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, 34 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
34 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, 35 const std::string& client_jid,
35 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 36 const base::Closure& disconnect_callback,
36 DesktopSessionConnector* desktop_session_connector, 37 base::WeakPtr<DesktopSessionConnector> desktop_session_connector)
37 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) 38 : caller_task_runner_(caller_task_runner),
38 : DesktopEnvironment( 39 connected_(false),
39 scoped_ptr<AudioCapturer>(
40 new IpcAudioCapturer(desktop_session_proxy)),
41 scoped_ptr<EventExecutor>(
42 new IpcEventExecutor(desktop_session_proxy)),
43 scoped_ptr<VideoFrameCapturer>(
44 new IpcVideoFrameCapturer(desktop_session_proxy))),
45 network_task_runner_(network_task_runner),
46 desktop_session_connector_(desktop_session_connector), 40 desktop_session_connector_(desktop_session_connector),
47 desktop_session_proxy_(desktop_session_proxy), 41 desktop_session_proxy_(new DesktopSessionProxy(caller_task_runner,
48 connected_(false) { 42 client_jid,
43 disconnect_callback)) {
44 DCHECK(caller_task_runner_->BelongsToCurrentThread());
49 } 45 }
50 46
51 IpcDesktopEnvironment::~IpcDesktopEnvironment() { 47 IpcDesktopEnvironment::~IpcDesktopEnvironment() {
52 if (connected_) { 48 DCHECK(caller_task_runner_->BelongsToCurrentThread());
53 connected_ = false; 49
50 if (connected_ && desktop_session_connector_)
54 desktop_session_connector_->DisconnectTerminal(desktop_session_proxy_); 51 desktop_session_connector_->DisconnectTerminal(desktop_session_proxy_);
52
53 connected_ = false;
54 desktop_session_proxy_->Stop();
55 }
56
57 void IpcDesktopEnvironment::InjectClipboardEvent(
58 const protocol::ClipboardEvent& event) {
59 DCHECK(caller_task_runner_->BelongsToCurrentThread());
60
61 desktop_session_proxy_->InjectClipboardEvent(event);
62 }
63
64 void IpcDesktopEnvironment::InjectKeyEvent(const protocol::KeyEvent& event) {
65 DCHECK(caller_task_runner_->BelongsToCurrentThread());
66
67 desktop_session_proxy_->InjectKeyEvent(event);
68 }
69
70 void IpcDesktopEnvironment::InjectMouseEvent(
71 const protocol::MouseEvent& event) {
72 DCHECK(caller_task_runner_->BelongsToCurrentThread());
73
74 desktop_session_proxy_->InjectMouseEvent(event);
75 }
76
77 void IpcDesktopEnvironment::StartAudio(
78 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner,
79 scoped_ptr<AudioEncoder> audio_encoder,
80 protocol::AudioStub* audio_stub) {
81 DCHECK(caller_task_runner_->BelongsToCurrentThread());
82
83 RegisterDesktopSessionProxy();
84 desktop_session_proxy_->StartAudio(audio_task_runner, audio_encoder.Pass(),
85 audio_stub);
86 }
87
88 void IpcDesktopEnvironment::PauseAudio(bool pause) {
89 DCHECK(caller_task_runner_->BelongsToCurrentThread());
90
91 desktop_session_proxy_->PauseAudio(pause);
92 }
93
94 void IpcDesktopEnvironment::StartInput(
95 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
96 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
97 protocol::ClipboardStub* clipboard_stub) {
98 DCHECK(caller_task_runner_->BelongsToCurrentThread());
99
100 RegisterDesktopSessionProxy();
101 desktop_session_proxy_->StartInput(input_task_runner, ui_task_runner,
102 clipboard_stub);
103 }
104
105 void IpcDesktopEnvironment::StartVideo(
106 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
107 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
108 scoped_ptr<VideoEncoder> video_encoder,
109 protocol::CursorShapeStub* cursor_shape_stub,
110 protocol::VideoStub* video_stub) {
111 DCHECK(caller_task_runner_->BelongsToCurrentThread());
112
113 RegisterDesktopSessionProxy();
114 desktop_session_proxy_->StartVideo(capture_task_runner,
115 encode_task_runner,
116 video_encoder.Pass(),
117 cursor_shape_stub,
118 video_stub);
119 }
120
121 SkISize IpcDesktopEnvironment::GetScreenSize() const {
122 return desktop_session_proxy_->GetScreenSize();
123 }
124
125 void IpcDesktopEnvironment::PauseVideo(bool pause) {
126 DCHECK(caller_task_runner_->BelongsToCurrentThread());
127
128 desktop_session_proxy_->PauseVideo(pause);
129 }
130
131 void IpcDesktopEnvironment::UpdateSequenceNumber(int64 sequence_number) {
132 DCHECK(caller_task_runner_->BelongsToCurrentThread());
133
134 desktop_session_proxy_->UpdateSequenceNumber(sequence_number);
135 }
136
137 void IpcDesktopEnvironment::RegisterDesktopSessionProxy() {
138 DCHECK(caller_task_runner_->BelongsToCurrentThread());
139
140 if (!connected_) {
141 connected_ = true;
142 desktop_session_connector_->ConnectTerminal(desktop_session_proxy_);
55 } 143 }
56 } 144 }
57 145
58 void IpcDesktopEnvironment::Start(
59 scoped_ptr<protocol::ClipboardStub> client_clipboard,
60 const std::string& client_jid,
61 const base::Closure& disconnect_callback) {
62 DCHECK(network_task_runner_->BelongsToCurrentThread());
63 DCHECK(!connected_);
64
65 desktop_session_proxy_->Initialize(client_jid, disconnect_callback);
66
67 // Register the proxy to receive AttachToDesktop() and DetachFromDesktop()
68 // notifications.
69 connected_ = true;
70 desktop_session_connector_->ConnectTerminal(desktop_session_proxy_);
71
72 DesktopEnvironment::Start(client_clipboard.Pass(), client_jid,
73 disconnect_callback);
74 }
75
76 } // namespace remoting 146 } // namespace remoting
OLDNEW
« 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