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

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

Issue 11028128: [Chromoting] Request the daemon to open a terminal once a connection has been accepted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feeback and rebased on top of https://chromiumcodereview.appspot.com/11017065/ Created 8 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/host/ipc_desktop_environment_factory.h"
6
7 #include <utility>
8
9 #include "ipc/ipc_channel_proxy.h"
10 #include "remoting/host/audio_capturer.h"
11 #include "remoting/host/chromoting_host.h"
12 #include "remoting/host/chromoting_host_context.h"
13 #include "remoting/host/chromoting_messages.h"
14 #include "remoting/host/desktop_session_connector.h"
15 #include "remoting/host/event_executor.h"
16 #include "remoting/host/ipc_desktop_environment.h"
17 #include "remoting/host/video_frame_capturer.h"
18 #include "remoting/host/win/session_event_executor.h"
19
20 namespace remoting {
21
22 int IpcDesktopEnvironmentFactory::next_id_ = 0;
23
24 IpcDesktopEnvironmentFactory::IpcDesktopEnvironmentFactory(
25 IPC::ChannelProxy* daemon_channel,
26 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
27 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
29 : DesktopEnvironmentFactory(input_task_runner, ui_task_runner),
30 daemon_channel_(daemon_channel),
31 network_task_runner_(network_task_runner) {
32 }
33
34 IpcDesktopEnvironmentFactory::~IpcDesktopEnvironmentFactory() {
35 }
36
37 scoped_ptr<DesktopEnvironment> IpcDesktopEnvironmentFactory::Create(
38 scoped_refptr<ChromotingHost> host) {
39 DCHECK(network_task_runner_->BelongsToCurrentThread());
40
41 scoped_ptr<AudioCapturer> audio_capturer = AudioCapturer::Create();
42 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create(
43 input_task_runner_, ui_task_runner_);
44 event_executor.reset(new SessionEventExecutorWin(
45 input_task_runner_, event_executor.Pass()));
46 scoped_ptr<VideoFrameCapturer> video_capturer(VideoFrameCapturer::Create());
47 return scoped_ptr<DesktopEnvironment>(new IpcDesktopEnvironment(
48 audio_capturer.Pass(),
49 event_executor.Pass(),
50 video_capturer.Pass(),
51 this,
52 host));
53 }
54
55 void IpcDesktopEnvironmentFactory::ConnectTerminal(
56 IpcDesktopEnvironment* desktop_environment) {
57 DCHECK(network_task_runner_->BelongsToCurrentThread());
58
59 int id = next_id_++;
60 bool inserted = active_connections_.insert(
61 std::make_pair(id, desktop_environment)).second;
62 CHECK(inserted);
63
64 VLOG(1) << "Network: registered desktop environment " << id;
65 daemon_channel_->Send(new ChromotingNetworkHostMsg_ConnectTerminal(id));
66 }
67
68 void IpcDesktopEnvironmentFactory::DisconnectTerminal(
69 IpcDesktopEnvironment* desktop_environment) {
70 DCHECK(network_task_runner_->BelongsToCurrentThread());
71
72 ActiveConnectionsList::iterator i;
73 for (i = active_connections_.begin(); i != active_connections_.end(); ++i) {
74 if (i->second == desktop_environment)
75 break;
76 }
77
78 if (i != active_connections_.end()) {
79 int id = i->first;
80 active_connections_.erase(i);
81
82 VLOG(1) << "Network: unregistered desktop environment " << id;
83 daemon_channel_->Send(new ChromotingNetworkHostMsg_DisconnectTerminal(id));
84 }
85 }
86
87 void IpcDesktopEnvironmentFactory::OnTerminalDisconnected(int terminal_id) {
88 if (!network_task_runner_->BelongsToCurrentThread()) {
89 network_task_runner_->PostTask(FROM_HERE, base::Bind(
90 &IpcDesktopEnvironmentFactory::OnTerminalDisconnected,
91 base::Unretained(this), terminal_id));
92 return;
93 }
94
95 ActiveConnectionsList::iterator i =
96 active_connections_.find(terminal_id);
97 if (i != active_connections_.end()) {
98 IpcDesktopEnvironment* desktop_environment = i->second;
99 active_connections_.erase(i);
100
101 // Disconnect the client for the given desktop environment.
102 desktop_environment->DisconnectClient();
103 }
104 }
105
106 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698