| 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_FACTORY_H_ | 5 #ifndef REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_FACTORY_H_ |
| 6 #define REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_FACTORY_H_ | 6 #define REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_FACTORY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 12 #include "remoting/host/desktop_environment_factory.h" | 13 #include "remoting/host/desktop_environment_factory.h" |
| 13 #include "remoting/host/desktop_session_connector.h" | 14 #include "remoting/host/desktop_session_connector.h" |
| 14 | 15 |
| 15 namespace IPC { | 16 namespace IPC { |
| 16 class ChannelProxy; | 17 class ChannelProxy; |
| 17 } // namespace IPC | 18 } // namespace IPC |
| 18 | 19 |
| 19 namespace remoting { | 20 namespace remoting { |
| 20 | 21 |
| 21 class DesktopSessionConnector; | 22 class DesktopSessionConnector; |
| 22 class DesktopSessionProxy; | 23 class DesktopSessionProxy; |
| 23 | 24 |
| 24 // Used to create IpcDesktopEnvironment objects intergating with the desktop via | 25 // Used to create IpcDesktopEnvironment objects intergating with the desktop via |
| 25 // a helper process and talking to that process via IPC. | 26 // a helper process and talking to that process via IPC. |
| 26 class IpcDesktopEnvironmentFactory | 27 class IpcDesktopEnvironmentFactory |
| 27 : public DesktopEnvironmentFactory, | 28 : public DesktopEnvironmentFactory, |
| 28 public DesktopSessionConnector { | 29 public DesktopSessionConnector { |
| 29 public: | 30 public: |
| 30 // Passes a reference to the IPC channel connected to the daemon process and | 31 // Passes a reference to the IPC channel connected to the daemon process and |
| 31 // relevant task runners. |daemon_channel| must outlive this object. | 32 // relevant task runners. |daemon_channel| must outlive this object. |
| 32 IpcDesktopEnvironmentFactory( | 33 IpcDesktopEnvironmentFactory( |
| 33 IPC::ChannelProxy* daemon_channel, | 34 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 34 scoped_refptr<base::SingleThreadTaskRunner> audio_capture_task_runner, | 35 IPC::ChannelProxy* daemon_channel); |
| 35 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | |
| 36 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | |
| 37 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | |
| 38 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner); | |
| 39 virtual ~IpcDesktopEnvironmentFactory(); | 36 virtual ~IpcDesktopEnvironmentFactory(); |
| 40 | 37 |
| 41 virtual scoped_ptr<DesktopEnvironment> Create() OVERRIDE; | 38 virtual scoped_ptr<DesktopEnvironment> Create( |
| 39 const std::string& client_jid, |
| 40 const base::Closure& disconnect_callback) OVERRIDE; |
| 42 | 41 |
| 43 // DesktopSessionConnector implementation. | 42 // DesktopSessionConnector implementation. |
| 44 virtual void ConnectTerminal( | 43 virtual void ConnectTerminal( |
| 45 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 44 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; |
| 46 virtual void DisconnectTerminal( | 45 virtual void DisconnectTerminal( |
| 47 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 46 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; |
| 48 virtual void OnDesktopSessionAgentAttached( | 47 virtual void OnDesktopSessionAgentAttached( |
| 49 int terminal_id, | 48 int terminal_id, |
| 50 IPC::PlatformFileForTransit desktop_process, | 49 IPC::PlatformFileForTransit desktop_process, |
| 51 IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; | 50 IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; |
| 52 virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE; | 51 virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE; |
| 53 | 52 |
| 54 private: | 53 private: |
| 54 // Task runner on which public methods of this class should be called. |
| 55 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
| 56 |
| 55 // IPC channel connected to the daemon process. | 57 // IPC channel connected to the daemon process. |
| 56 IPC::ChannelProxy* daemon_channel_; | 58 IPC::ChannelProxy* daemon_channel_; |
| 57 | 59 |
| 58 // Task runner used to run the audio capturer. | |
| 59 scoped_refptr<base::SingleThreadTaskRunner> audio_capture_task_runner_; | |
| 60 | |
| 61 // Task runner used to service calls to the DesktopSessionConnector APIs. | |
| 62 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | |
| 63 | |
| 64 // Task runner used to run the video capturer. | |
| 65 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_; | |
| 66 | |
| 67 // List of DesktopEnvironment instances we've told the daemon process about. | 60 // List of DesktopEnvironment instances we've told the daemon process about. |
| 68 typedef std::map<int, scoped_refptr<DesktopSessionProxy> > | 61 typedef std::map<int, scoped_refptr<DesktopSessionProxy> > |
| 69 ActiveConnectionsList; | 62 ActiveConnectionsList; |
| 70 ActiveConnectionsList active_connections_; | 63 ActiveConnectionsList active_connections_; |
| 71 | 64 |
| 65 // Factory for weak pointers to DesktopSessionConnector interface. |
| 66 base::WeakPtrFactory<DesktopSessionConnector> connector_factory_; |
| 67 |
| 72 // Next desktop session ID. IDs are allocated sequentially starting from 0. | 68 // Next desktop session ID. IDs are allocated sequentially starting from 0. |
| 73 // This gives us more than 67 years of unique IDs assuming a new ID is | 69 // This gives us more than 67 years of unique IDs assuming a new ID is |
| 74 // allocated every second. | 70 // allocated every second. |
| 75 int next_id_; | 71 int next_id_; |
| 76 | 72 |
| 77 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory); | 73 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory); |
| 78 }; | 74 }; |
| 79 | 75 |
| 80 } // namespace remoting | 76 } // namespace remoting |
| 81 | 77 |
| 82 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_FACTORY_H_ | 78 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_FACTORY_H_ |
| OLD | NEW |