| OLD | NEW |
| (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 #ifndef REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_FACTORY_H_ | |
| 6 #define REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_FACTORY_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "remoting/host/desktop_environment_factory.h" | |
| 13 #include "remoting/host/desktop_session_connector.h" | |
| 14 | |
| 15 namespace IPC { | |
| 16 class ChannelProxy; | |
| 17 } // namespace IPC | |
| 18 | |
| 19 namespace remoting { | |
| 20 | |
| 21 class DesktopSessionConnector; | |
| 22 class DesktopSessionProxy; | |
| 23 | |
| 24 // Used to create IpcDesktopEnvironment objects intergating with the desktop via | |
| 25 // a helper process and talking to that process via IPC. | |
| 26 class IpcDesktopEnvironmentFactory | |
| 27 : public DesktopEnvironmentFactory, | |
| 28 public DesktopSessionConnector { | |
| 29 public: | |
| 30 // Passes a reference to the IPC channel connected to the daemon process and | |
| 31 // relevant task runners. |daemon_channel| must outlive this object. | |
| 32 IpcDesktopEnvironmentFactory( | |
| 33 IPC::ChannelProxy* daemon_channel, | |
| 34 scoped_refptr<base::SingleThreadTaskRunner> audio_capture_task_runner, | |
| 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(); | |
| 40 | |
| 41 virtual scoped_ptr<DesktopEnvironment> Create() OVERRIDE; | |
| 42 | |
| 43 // DesktopSessionConnector implementation. | |
| 44 virtual void ConnectTerminal( | |
| 45 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | |
| 46 virtual void DisconnectTerminal( | |
| 47 scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | |
| 48 virtual void OnDesktopSessionAgentAttached( | |
| 49 int terminal_id, | |
| 50 IPC::PlatformFileForTransit desktop_process, | |
| 51 IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; | |
| 52 virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE; | |
| 53 | |
| 54 private: | |
| 55 // IPC channel connected to the daemon process. | |
| 56 IPC::ChannelProxy* daemon_channel_; | |
| 57 | |
| 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. | |
| 68 typedef std::map<int, scoped_refptr<DesktopSessionProxy> > | |
| 69 ActiveConnectionsList; | |
| 70 ActiveConnectionsList active_connections_; | |
| 71 | |
| 72 // 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 | |
| 74 // allocated every second. | |
| 75 int next_id_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory); | |
| 78 }; | |
| 79 | |
| 80 } // namespace remoting | |
| 81 | |
| 82 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_FACTORY_H_ | |
| OLD | NEW |