OLD | NEW |
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 #ifndef REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ | 5 #ifndef REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ |
6 #define REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ | 6 #define REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "remoting/host/desktop_environment.h" | 16 #include "remoting/host/desktop_environment.h" |
17 #include "remoting/host/desktop_session_connector.h" | 17 #include "remoting/host/desktop_session_connector.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
21 } // base | 21 } // base |
22 | 22 |
23 namespace IPC { | 23 namespace IPC { |
24 class ChannelProxy; | 24 class Sender; |
25 } // namespace IPC | 25 } // namespace IPC |
26 | 26 |
27 namespace remoting { | 27 namespace remoting { |
28 | 28 |
29 class DesktopSessionProxy; | 29 class DesktopSessionProxy; |
30 | 30 |
31 // A variant of desktop environment integrating with the desktop by means of | 31 // A variant of desktop environment integrating with the desktop by means of |
32 // a helper process and talking to that process via IPC. | 32 // a helper process and talking to that process via IPC. |
33 class IpcDesktopEnvironment : public DesktopEnvironment { | 33 class IpcDesktopEnvironment : public DesktopEnvironment { |
34 public: | 34 public: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // a helper process and talking to that process via IPC. | 76 // a helper process and talking to that process via IPC. |
77 class IpcDesktopEnvironmentFactory | 77 class IpcDesktopEnvironmentFactory |
78 : public DesktopEnvironmentFactory, | 78 : public DesktopEnvironmentFactory, |
79 public DesktopSessionConnector { | 79 public DesktopSessionConnector { |
80 public: | 80 public: |
81 // Passes a reference to the IPC channel connected to the daemon process and | 81 // Passes a reference to the IPC channel connected to the daemon process and |
82 // relevant task runners. |daemon_channel| must outlive this object. | 82 // relevant task runners. |daemon_channel| must outlive this object. |
83 IpcDesktopEnvironmentFactory( | 83 IpcDesktopEnvironmentFactory( |
84 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 84 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
85 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 85 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
86 IPC::ChannelProxy* daemon_channel); | 86 IPC::Sender* daemon_channel); |
87 virtual ~IpcDesktopEnvironmentFactory(); | 87 virtual ~IpcDesktopEnvironmentFactory(); |
88 | 88 |
89 // DesktopEnvironmentFactory implementation. | 89 // DesktopEnvironmentFactory implementation. |
90 virtual scoped_ptr<DesktopEnvironment> Create( | 90 virtual scoped_ptr<DesktopEnvironment> Create( |
91 const std::string& client_jid, | 91 const std::string& client_jid, |
92 const base::Closure& disconnect_callback) OVERRIDE; | 92 const base::Closure& disconnect_callback) OVERRIDE; |
93 virtual bool SupportsAudioCapture() const OVERRIDE; | 93 virtual bool SupportsAudioCapture() const OVERRIDE; |
94 | 94 |
95 // DesktopSessionConnector implementation. | 95 // DesktopSessionConnector implementation. |
96 virtual void ConnectTerminal( | 96 virtual void ConnectTerminal( |
97 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 97 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; |
98 virtual void DisconnectTerminal( | 98 virtual void DisconnectTerminal( |
99 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 99 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; |
100 virtual void OnDesktopSessionAgentAttached( | 100 virtual void OnDesktopSessionAgentAttached( |
101 int terminal_id, | 101 int terminal_id, |
102 base::ProcessHandle desktop_process, | 102 base::ProcessHandle desktop_process, |
103 IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; | 103 IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; |
104 virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE; | 104 virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE; |
105 | 105 |
106 private: | 106 private: |
107 // Task runner on which public methods of this class should be called. | 107 // Task runner on which public methods of this class should be called. |
108 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | 108 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
109 | 109 |
110 // Task runner used for running background I/O. | 110 // Task runner used for running background I/O. |
111 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 111 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
112 | 112 |
113 // IPC channel connected to the daemon process. | 113 // IPC channel connected to the daemon process. |
114 IPC::ChannelProxy* daemon_channel_; | 114 IPC::Sender* daemon_channel_; |
115 | 115 |
116 // List of DesktopEnvironment instances we've told the daemon process about. | 116 // List of DesktopEnvironment instances we've told the daemon process about. |
117 typedef std::map<int, scoped_refptr<DesktopSessionProxy> > | 117 typedef std::map<int, scoped_refptr<DesktopSessionProxy> > |
118 ActiveConnectionsList; | 118 ActiveConnectionsList; |
119 ActiveConnectionsList active_connections_; | 119 ActiveConnectionsList active_connections_; |
120 | 120 |
121 // Factory for weak pointers to DesktopSessionConnector interface. | 121 // Factory for weak pointers to DesktopSessionConnector interface. |
122 base::WeakPtrFactory<DesktopSessionConnector> connector_factory_; | 122 base::WeakPtrFactory<DesktopSessionConnector> connector_factory_; |
123 | 123 |
124 // Next desktop session ID. IDs are allocated sequentially starting from 0. | 124 // Next desktop session ID. IDs are allocated sequentially starting from 0. |
125 // This gives us more than 67 years of unique IDs assuming a new ID is | 125 // This gives us more than 67 years of unique IDs assuming a new ID is |
126 // allocated every second. | 126 // allocated every second. |
127 int next_id_; | 127 int next_id_; |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory); | 129 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory); |
130 }; | 130 }; |
131 | 131 |
132 } // namespace remoting | 132 } // namespace remoting |
133 | 133 |
134 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ | 134 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ |
OLD | NEW |