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

Unified 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: rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/ipc_desktop_environment_factory.h ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/ipc_desktop_environment_factory.cc
diff --git a/remoting/host/ipc_desktop_environment_factory.cc b/remoting/host/ipc_desktop_environment_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..07c35803d188c852274861cc72ec987025287740
--- /dev/null
+++ b/remoting/host/ipc_desktop_environment_factory.cc
@@ -0,0 +1,94 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/ipc_desktop_environment_factory.h"
+
+#include <utility>
+
+#include "ipc/ipc_channel_proxy.h"
+#include "remoting/host/audio_capturer.h"
+#include "remoting/host/chromoting_host.h"
+#include "remoting/host/chromoting_host_context.h"
+#include "remoting/host/chromoting_messages.h"
+#include "remoting/host/desktop_session_connector.h"
+#include "remoting/host/event_executor.h"
+#include "remoting/host/ipc_desktop_environment.h"
+#include "remoting/host/video_frame_capturer.h"
+
+namespace remoting {
+
+IpcDesktopEnvironmentFactory::IpcDesktopEnvironmentFactory(
+ IPC::ChannelProxy* daemon_channel,
+ scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
+ : DesktopEnvironmentFactory(input_task_runner, ui_task_runner),
+ daemon_channel_(daemon_channel),
+ network_task_runner_(network_task_runner),
+ next_id_(0) {
+}
+
+IpcDesktopEnvironmentFactory::~IpcDesktopEnvironmentFactory() {
+}
+
+scoped_ptr<DesktopEnvironment> IpcDesktopEnvironmentFactory::Create(
+ ClientSession* client) {
+ DCHECK(network_task_runner_->BelongsToCurrentThread());
+
+ return scoped_ptr<DesktopEnvironment>(new IpcDesktopEnvironment(
+ input_task_runner_, ui_task_runner_, this, client));
+}
+
+void IpcDesktopEnvironmentFactory::ConnectTerminal(
+ IpcDesktopEnvironment* desktop_environment) {
+ DCHECK(network_task_runner_->BelongsToCurrentThread());
+
+ int id = next_id_++;
+ bool inserted = active_connections_.insert(
+ std::make_pair(id, desktop_environment)).second;
+ CHECK(inserted);
+
+ VLOG(1) << "Network: registered desktop environment " << id;
+ daemon_channel_->Send(new ChromotingNetworkHostMsg_ConnectTerminal(id));
+}
+
+void IpcDesktopEnvironmentFactory::DisconnectTerminal(
+ IpcDesktopEnvironment* desktop_environment) {
+ DCHECK(network_task_runner_->BelongsToCurrentThread());
+
+ ActiveConnectionsList::iterator i;
+ for (i = active_connections_.begin(); i != active_connections_.end(); ++i) {
+ if (i->second == desktop_environment)
+ break;
+ }
+
+ if (i != active_connections_.end()) {
+ int id = i->first;
+ active_connections_.erase(i);
+
+ VLOG(1) << "Network: unregistered desktop environment " << id;
+ daemon_channel_->Send(new ChromotingNetworkHostMsg_DisconnectTerminal(id));
+ }
+}
+
+void IpcDesktopEnvironmentFactory::OnTerminalDisconnected(int terminal_id) {
+ if (!network_task_runner_->BelongsToCurrentThread()) {
+ network_task_runner_->PostTask(FROM_HERE, base::Bind(
+ &IpcDesktopEnvironmentFactory::OnTerminalDisconnected,
+ base::Unretained(this), terminal_id));
+ return;
+ }
+
+ ActiveConnectionsList::iterator i =
+ active_connections_.find(terminal_id);
+ if (i != active_connections_.end()) {
+ IpcDesktopEnvironment* desktop_environment = i->second;
+ active_connections_.erase(i);
+
+ // Disconnect the client for the given desktop environment.
+ desktop_environment->DisconnectClient();
+ }
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/ipc_desktop_environment_factory.h ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698