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

Side by Side Diff: remoting/host/desktop_session_agent.cc

Issue 12594009: Converted LocalInputMonitor into a SessionController instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 9 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
« no previous file with comments | « remoting/host/desktop_session_agent.h ('k') | remoting/host/host_mock_objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/desktop_session_agent.h" 5 #include "remoting/host/desktop_session_agent.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ipc/ipc_channel_proxy.h" 9 #include "ipc/ipc_channel_proxy.h"
10 #include "ipc/ipc_message.h" 10 #include "ipc/ipc_message.h"
11 #include "ipc/ipc_message_macros.h" 11 #include "ipc/ipc_message_macros.h"
12 #include "media/video/capture/screen/screen_capture_data.h" 12 #include "media/video/capture/screen/screen_capture_data.h"
13 #include "remoting/base/auto_thread_task_runner.h" 13 #include "remoting/base/auto_thread_task_runner.h"
14 #include "remoting/base/constants.h" 14 #include "remoting/base/constants.h"
15 #include "remoting/host/audio_capturer.h" 15 #include "remoting/host/audio_capturer.h"
16 #include "remoting/host/chromoting_messages.h" 16 #include "remoting/host/chromoting_messages.h"
17 #include "remoting/host/desktop_environment.h" 17 #include "remoting/host/desktop_environment.h"
18 #include "remoting/host/disconnect_window.h" 18 #include "remoting/host/disconnect_window.h"
19 #include "remoting/host/input_injector.h" 19 #include "remoting/host/input_injector.h"
20 #include "remoting/host/local_input_monitor.h"
21 #include "remoting/host/remote_input_filter.h" 20 #include "remoting/host/remote_input_filter.h"
22 #include "remoting/host/screen_controls.h" 21 #include "remoting/host/screen_controls.h"
23 #include "remoting/host/screen_resolution.h" 22 #include "remoting/host/screen_resolution.h"
24 #include "remoting/proto/audio.pb.h" 23 #include "remoting/proto/audio.pb.h"
25 #include "remoting/proto/control.pb.h" 24 #include "remoting/proto/control.pb.h"
26 #include "remoting/proto/event.pb.h" 25 #include "remoting/proto/event.pb.h"
27 #include "remoting/protocol/clipboard_stub.h" 26 #include "remoting/protocol/clipboard_stub.h"
28 #include "remoting/protocol/input_event_tracker.h" 27 #include "remoting/protocol/input_event_tracker.h"
29 #include "third_party/skia/include/core/SkRegion.h" 28 #include "third_party/skia/include/core/SkRegion.h"
30 29
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 63
65 } // namespace 64 } // namespace
66 65
67 DesktopSessionAgent::Delegate::~Delegate() { 66 DesktopSessionAgent::Delegate::~Delegate() {
68 } 67 }
69 68
70 DesktopSessionAgent::~DesktopSessionAgent() { 69 DesktopSessionAgent::~DesktopSessionAgent() {
71 DCHECK(!audio_capturer_); 70 DCHECK(!audio_capturer_);
72 DCHECK(!desktop_environment_); 71 DCHECK(!desktop_environment_);
73 DCHECK(!disconnect_window_); 72 DCHECK(!disconnect_window_);
74 DCHECK(!local_input_monitor_);
75 DCHECK(!network_channel_); 73 DCHECK(!network_channel_);
76 DCHECK(!screen_controls_); 74 DCHECK(!screen_controls_);
77 DCHECK(!video_capturer_); 75 DCHECK(!video_capturer_);
78 76
79 CloseDesktopPipeHandle(); 77 CloseDesktopPipeHandle();
80 } 78 }
81 79
82 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) { 80 bool DesktopSessionAgent::OnMessageReceived(const IPC::Message& message) {
83 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 81 DCHECK(caller_task_runner()->BelongsToCurrentThread());
84 82
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 189
192 void DesktopSessionAgent::OnStartSessionAgent( 190 void DesktopSessionAgent::OnStartSessionAgent(
193 const std::string& authenticated_jid, 191 const std::string& authenticated_jid,
194 const ScreenResolution& resolution) { 192 const ScreenResolution& resolution) {
195 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 193 DCHECK(caller_task_runner()->BelongsToCurrentThread());
196 DCHECK(!started_); 194 DCHECK(!started_);
197 DCHECK(!audio_capturer_); 195 DCHECK(!audio_capturer_);
198 DCHECK(!desktop_environment_); 196 DCHECK(!desktop_environment_);
199 DCHECK(!disconnect_window_); 197 DCHECK(!disconnect_window_);
200 DCHECK(!input_injector_); 198 DCHECK(!input_injector_);
201 DCHECK(!local_input_monitor_);
202 DCHECK(!screen_controls_); 199 DCHECK(!screen_controls_);
203 DCHECK(!video_capturer_); 200 DCHECK(!video_capturer_);
204 201
205 started_ = true; 202 started_ = true;
206 client_jid_ = authenticated_jid; 203 client_jid_ = authenticated_jid;
207 204
208 // Create a desktop environment for the new session. 205 // Create a desktop environment for the new session.
209 desktop_environment_ = delegate_->desktop_environment_factory().Create( 206 desktop_environment_ = delegate_->desktop_environment_factory().Create(
210 control_factory_.GetWeakPtr()); 207 control_factory_.GetWeakPtr());
211 208
(...skipping 13 matching lines...) Expand all
225 // reaches |remote_input_filter_|. 222 // reaches |remote_input_filter_|.
226 remote_input_filter_->SetExpectLocalEcho(false); 223 remote_input_filter_->SetExpectLocalEcho(false);
227 #endif // defined(OS_WIN) 224 #endif // defined(OS_WIN)
228 225
229 // Start the input injector. 226 // Start the input injector.
230 scoped_ptr<protocol::ClipboardStub> clipboard_stub( 227 scoped_ptr<protocol::ClipboardStub> clipboard_stub(
231 new DesktopSesssionClipboardStub(this)); 228 new DesktopSesssionClipboardStub(this));
232 input_injector_->Start(clipboard_stub.Pass()); 229 input_injector_->Start(clipboard_stub.Pass());
233 230
234 // Create the disconnect window. 231 // Create the disconnect window.
235 base::Closure disconnect_session =
236 base::Bind(&DesktopSessionAgent::DisconnectSession, this);
237 disconnect_window_ = DisconnectWindow::Create(&ui_strings_); 232 disconnect_window_ = DisconnectWindow::Create(&ui_strings_);
238 disconnect_window_->Show( 233 disconnect_window_->Show(
239 disconnect_session, 234 base::Bind(&DesktopSessionAgent::DisconnectSession, this),
240 authenticated_jid.substr(0, authenticated_jid.find('/'))); 235 authenticated_jid.substr(0, authenticated_jid.find('/')));
241 236
242 // Start monitoring local input.
243 local_input_monitor_ = LocalInputMonitor::Create(caller_task_runner_,
244 input_task_runner_,
245 caller_task_runner_);
246 local_input_monitor_->Start(this, disconnect_session);
247
248 // Start the audio capturer. 237 // Start the audio capturer.
249 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) { 238 if (delegate_->desktop_environment_factory().SupportsAudioCapture()) {
250 audio_capturer_ = desktop_environment_->CreateAudioCapturer(); 239 audio_capturer_ = desktop_environment_->CreateAudioCapturer();
251 audio_capture_task_runner()->PostTask( 240 audio_capture_task_runner()->PostTask(
252 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this)); 241 FROM_HERE, base::Bind(&DesktopSessionAgent::StartAudioCapturer, this));
253 } 242 }
254 243
255 // Start the video capturer. 244 // Start the video capturer.
256 video_capturer_ = desktop_environment_->CreateVideoCapturer(); 245 video_capturer_ = desktop_environment_->CreateVideoCapturer();
257 video_capture_task_runner()->PostTask( 246 video_capture_task_runner()->PostTask(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 started_ = false; 329 started_ = false;
341 330
342 // Close the disconnect window and stop listening to local input. 331 // Close the disconnect window and stop listening to local input.
343 disconnect_window_->Hide(); 332 disconnect_window_->Hide();
344 disconnect_window_.reset(); 333 disconnect_window_.reset();
345 334
346 // Ignore any further callbacks. 335 // Ignore any further callbacks.
347 control_factory_.InvalidateWeakPtrs(); 336 control_factory_.InvalidateWeakPtrs();
348 client_jid_.clear(); 337 client_jid_.clear();
349 338
350 // Stop monitoring to local input.
351 local_input_monitor_->Stop();
352 local_input_monitor_.reset();
353
354 remote_input_filter_.reset(); 339 remote_input_filter_.reset();
355 340
356 // Ensure that any pressed keys or buttons are released. 341 // Ensure that any pressed keys or buttons are released.
357 input_tracker_->ReleaseAll(); 342 input_tracker_->ReleaseAll();
358 input_tracker_.reset(); 343 input_tracker_.reset();
359 344
345 desktop_environment_.reset();
360 input_injector_.reset(); 346 input_injector_.reset();
361 screen_controls_.reset(); 347 screen_controls_.reset();
362 desktop_environment_.reset();
363 348
364 // Stop the audio capturer. 349 // Stop the audio capturer.
365 audio_capture_task_runner()->PostTask( 350 audio_capture_task_runner()->PostTask(
366 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this)); 351 FROM_HERE, base::Bind(&DesktopSessionAgent::StopAudioCapturer, this));
367 352
368 // Stop the video capturer. 353 // Stop the video capturer.
369 video_capture_task_runner()->PostTask( 354 video_capture_task_runner()->PostTask(
370 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this)); 355 FROM_HERE, base::Bind(&DesktopSessionAgent::StopVideoCapturer, this));
371 } 356 }
372 } 357 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 base::ClosePlatformFile(desktop_pipe_.fd); 550 base::ClosePlatformFile(desktop_pipe_.fd);
566 #else // !defined(OS_POSIX) 551 #else // !defined(OS_POSIX)
567 #error Unsupported platform. 552 #error Unsupported platform.
568 #endif // !defined(OS_POSIX) 553 #endif // !defined(OS_POSIX)
569 554
570 desktop_pipe_ = IPC::InvalidPlatformFileForTransit(); 555 desktop_pipe_ = IPC::InvalidPlatformFileForTransit();
571 } 556 }
572 } 557 }
573 558
574 } // namespace remoting 559 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_session_agent.h ('k') | remoting/host/host_mock_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698