| 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/curtain_mode.h" |
| 16 #include "remoting/host/desktop_environment.h" | 17 #include "remoting/host/desktop_environment.h" |
| 17 #include "remoting/host/desktop_session_connector.h" | 18 #include "remoting/host/desktop_session_connector.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
| 21 } // base | 22 } // base |
| 22 | 23 |
| 23 namespace IPC { | 24 namespace IPC { |
| 24 class Sender; | 25 class Sender; |
| 25 } // namespace IPC | 26 } // namespace IPC |
| 26 | 27 |
| 27 namespace remoting { | 28 namespace remoting { |
| 28 | 29 |
| 29 class DesktopSessionProxy; | 30 class DesktopSessionProxy; |
| 30 | 31 |
| 31 // A variant of desktop environment integrating with the desktop by means of | 32 // A variant of desktop environment integrating with the desktop by means of |
| 32 // a helper process and talking to that process via IPC. | 33 // a helper process and talking to that process via IPC. |
| 33 class IpcDesktopEnvironment : public DesktopEnvironment { | 34 class IpcDesktopEnvironment : public DesktopEnvironment { |
| 34 public: | 35 public: |
| 35 // |desktop_session_connector| is used to bind DesktopSessionProxy to | 36 // |desktop_session_connector| is used to bind DesktopSessionProxy to |
| 36 // a desktop session, to be notified every time the desktop process is | 37 // a desktop session, to be notified every time the desktop process is |
| 37 // restarted. | 38 // restarted. |
| 38 IpcDesktopEnvironment( | 39 IpcDesktopEnvironment( |
| 39 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 40 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 40 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 41 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 41 const std::string& client_jid, | 42 const std::string& client_jid, |
| 42 const base::Closure& disconnect_callback, | 43 const base::Closure& disconnect_callback, |
| 43 base::WeakPtr<DesktopSessionConnector> desktop_session_connector); | 44 base::WeakPtr<DesktopSessionConnector> desktop_session_connector, |
| 45 bool curtain_required); |
| 44 virtual ~IpcDesktopEnvironment(); | 46 virtual ~IpcDesktopEnvironment(); |
| 45 | 47 |
| 46 // DesktopEnvironment implementation. | 48 // DesktopEnvironment implementation. |
| 47 virtual scoped_ptr<AudioCapturer> CreateAudioCapturer( | 49 virtual scoped_ptr<AudioCapturer> CreateAudioCapturer( |
| 48 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner) OVERRIDE; | 50 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner) OVERRIDE; |
| 49 virtual scoped_ptr<EventExecutor> CreateEventExecutor( | 51 virtual scoped_ptr<EventExecutor> CreateEventExecutor( |
| 50 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 52 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 51 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) OVERRIDE; | 53 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) OVERRIDE; |
| 52 virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer( | 54 virtual scoped_ptr<media::ScreenCapturer> CreateVideoCapturer( |
| 53 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 55 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 base::WeakPtr<DesktopSessionConnector> desktop_session_connector_; | 70 base::WeakPtr<DesktopSessionConnector> desktop_session_connector_; |
| 69 | 71 |
| 70 scoped_refptr<DesktopSessionProxy> desktop_session_proxy_; | 72 scoped_refptr<DesktopSessionProxy> desktop_session_proxy_; |
| 71 | 73 |
| 72 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment); | 74 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment); |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 // Used to create IpcDesktopEnvironment objects integrating with the desktop via | 77 // Used to create IpcDesktopEnvironment objects integrating with the desktop via |
| 76 // a helper process and talking to that process via IPC. | 78 // a helper process and talking to that process via IPC. |
| 77 class IpcDesktopEnvironmentFactory | 79 class IpcDesktopEnvironmentFactory |
| 78 : public DesktopEnvironmentFactory, | 80 : public CurtainMode, |
| 81 public DesktopEnvironmentFactory, |
| 79 public DesktopSessionConnector { | 82 public DesktopSessionConnector { |
| 80 public: | 83 public: |
| 81 // Passes a reference to the IPC channel connected to the daemon process and | 84 // Passes a reference to the IPC channel connected to the daemon process and |
| 82 // relevant task runners. |daemon_channel| must outlive this object. | 85 // relevant task runners. |daemon_channel| must outlive this object. |
| 83 IpcDesktopEnvironmentFactory( | 86 IpcDesktopEnvironmentFactory( |
| 84 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 87 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 85 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 88 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 86 IPC::Sender* daemon_channel); | 89 IPC::Sender* daemon_channel); |
| 87 virtual ~IpcDesktopEnvironmentFactory(); | 90 virtual ~IpcDesktopEnvironmentFactory(); |
| 88 | 91 |
| 92 // CurtainMode implementation. |
| 93 virtual void SetActivated(bool activated) OVERRIDE; |
| 94 |
| 89 // DesktopEnvironmentFactory implementation. | 95 // DesktopEnvironmentFactory implementation. |
| 90 virtual scoped_ptr<DesktopEnvironment> Create( | 96 virtual scoped_ptr<DesktopEnvironment> Create( |
| 91 const std::string& client_jid, | 97 const std::string& client_jid, |
| 92 const base::Closure& disconnect_callback) OVERRIDE; | 98 const base::Closure& disconnect_callback) OVERRIDE; |
| 93 virtual bool SupportsAudioCapture() const OVERRIDE; | 99 virtual bool SupportsAudioCapture() const OVERRIDE; |
| 94 | 100 |
| 95 // DesktopSessionConnector implementation. | 101 // DesktopSessionConnector implementation. |
| 96 virtual void ConnectTerminal( | 102 virtual void ConnectTerminal( |
| 97 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 103 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; |
| 98 virtual void DisconnectTerminal( | 104 virtual void DisconnectTerminal( |
| 99 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 105 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; |
| 100 virtual void OnDesktopSessionAgentAttached( | 106 virtual void OnDesktopSessionAgentAttached( |
| 101 int terminal_id, | 107 int terminal_id, |
| 102 base::ProcessHandle desktop_process, | 108 base::ProcessHandle desktop_process, |
| 103 IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; | 109 IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; |
| 104 virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE; | 110 virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE; |
| 105 | 111 |
| 106 private: | 112 private: |
| 107 // Task runner on which public methods of this class should be called. | 113 // Task runner on which public methods of this class should be called. |
| 108 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | 114 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
| 109 | 115 |
| 110 // Task runner used for running background I/O. | 116 // Task runner used for running background I/O. |
| 111 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 117 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 112 | 118 |
| 119 // True if curtain mode is activated. |
| 120 bool curtain_activated_; |
| 121 |
| 113 // IPC channel connected to the daemon process. | 122 // IPC channel connected to the daemon process. |
| 114 IPC::Sender* daemon_channel_; | 123 IPC::Sender* daemon_channel_; |
| 115 | 124 |
| 116 // List of DesktopEnvironment instances we've told the daemon process about. | 125 // List of DesktopEnvironment instances we've told the daemon process about. |
| 117 typedef std::map<int, scoped_refptr<DesktopSessionProxy> > | 126 typedef std::map<int, scoped_refptr<DesktopSessionProxy> > |
| 118 ActiveConnectionsList; | 127 ActiveConnectionsList; |
| 119 ActiveConnectionsList active_connections_; | 128 ActiveConnectionsList active_connections_; |
| 120 | 129 |
| 121 // Factory for weak pointers to DesktopSessionConnector interface. | 130 // Factory for weak pointers to DesktopSessionConnector interface. |
| 122 base::WeakPtrFactory<DesktopSessionConnector> connector_factory_; | 131 base::WeakPtrFactory<DesktopSessionConnector> connector_factory_; |
| 123 | 132 |
| 124 // Next desktop session ID. IDs are allocated sequentially starting from 0. | 133 // 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 | 134 // This gives us more than 67 years of unique IDs assuming a new ID is |
| 126 // allocated every second. | 135 // allocated every second. |
| 127 int next_id_; | 136 int next_id_; |
| 128 | 137 |
| 129 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory); | 138 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory); |
| 130 }; | 139 }; |
| 131 | 140 |
| 132 } // namespace remoting | 141 } // namespace remoting |
| 133 | 142 |
| 134 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ | 143 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ |
| OLD | NEW |