| 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 | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 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: | 
| 35   // |desktop_session_connector| is used to bind DesktopSessionProxy to | 35   // |desktop_session_connector| is used to bind DesktopSessionProxy to | 
| 36   // a desktop session, to be notified every time the desktop process is | 36   // a desktop session, to be notified every time the desktop process is | 
| 37   // restarted. | 37   // restarted. | 
| 38   IpcDesktopEnvironment( | 38   IpcDesktopEnvironment( | 
| 39       scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 39       scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 
|  | 40       scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 
| 40       const std::string& client_jid, | 41       const std::string& client_jid, | 
| 41       const base::Closure& disconnect_callback, | 42       const base::Closure& disconnect_callback, | 
| 42       base::WeakPtr<DesktopSessionConnector> desktop_session_connector); | 43       base::WeakPtr<DesktopSessionConnector> desktop_session_connector); | 
| 43   virtual ~IpcDesktopEnvironment(); | 44   virtual ~IpcDesktopEnvironment(); | 
| 44 | 45 | 
| 45   // DesktopEnvironment implementation. | 46   // DesktopEnvironment implementation. | 
| 46   virtual scoped_ptr<AudioCapturer> CreateAudioCapturer( | 47   virtual scoped_ptr<AudioCapturer> CreateAudioCapturer( | 
| 47       scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner) OVERRIDE; | 48       scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner) OVERRIDE; | 
| 48   virtual scoped_ptr<EventExecutor> CreateEventExecutor( | 49   virtual scoped_ptr<EventExecutor> CreateEventExecutor( | 
| 49       scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 50       scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 74 // Used to create IpcDesktopEnvironment objects integrating with the desktop via | 75 // Used to create IpcDesktopEnvironment objects integrating with the desktop via | 
| 75 // a helper process and talking to that process via IPC. | 76 // a helper process and talking to that process via IPC. | 
| 76 class IpcDesktopEnvironmentFactory | 77 class IpcDesktopEnvironmentFactory | 
| 77     : public DesktopEnvironmentFactory, | 78     : public DesktopEnvironmentFactory, | 
| 78       public DesktopSessionConnector { | 79       public DesktopSessionConnector { | 
| 79  public: | 80  public: | 
| 80   // 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 | 
| 81   // relevant task runners. |daemon_channel| must outlive this object. | 82   // relevant task runners. |daemon_channel| must outlive this object. | 
| 82   IpcDesktopEnvironmentFactory( | 83   IpcDesktopEnvironmentFactory( | 
| 83       scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 84       scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 
|  | 85       scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 
| 84       IPC::ChannelProxy* daemon_channel); | 86       IPC::ChannelProxy* daemon_channel); | 
| 85   virtual ~IpcDesktopEnvironmentFactory(); | 87   virtual ~IpcDesktopEnvironmentFactory(); | 
| 86 | 88 | 
| 87   // DesktopEnvironmentFactory implementation. | 89   // DesktopEnvironmentFactory implementation. | 
| 88   virtual scoped_ptr<DesktopEnvironment> Create( | 90   virtual scoped_ptr<DesktopEnvironment> Create( | 
| 89       const std::string& client_jid, | 91       const std::string& client_jid, | 
| 90       const base::Closure& disconnect_callback) OVERRIDE; | 92       const base::Closure& disconnect_callback) OVERRIDE; | 
| 91   virtual bool SupportsAudioCapture() const OVERRIDE; | 93   virtual bool SupportsAudioCapture() const OVERRIDE; | 
| 92 | 94 | 
| 93   // DesktopSessionConnector implementation. | 95   // DesktopSessionConnector implementation. | 
| 94   virtual void ConnectTerminal( | 96   virtual void ConnectTerminal( | 
| 95       scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 97       scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 
| 96   virtual void DisconnectTerminal( | 98   virtual void DisconnectTerminal( | 
| 97       scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 99       scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE; | 
| 98   virtual void OnDesktopSessionAgentAttached( | 100   virtual void OnDesktopSessionAgentAttached( | 
| 99       int terminal_id, | 101       int terminal_id, | 
| 100       IPC::PlatformFileForTransit desktop_process, | 102       base::ProcessHandle desktop_process, | 
| 101       IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; | 103       IPC::PlatformFileForTransit desktop_pipe) OVERRIDE; | 
| 102   virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE; | 104   virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE; | 
| 103 | 105 | 
| 104  private: | 106  private: | 
| 105   // 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. | 
| 106   scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | 108   scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | 
| 107 | 109 | 
|  | 110   // Task runner used for running background I/O. | 
|  | 111   scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 
|  | 112 | 
| 108   // IPC channel connected to the daemon process. | 113   // IPC channel connected to the daemon process. | 
| 109   IPC::ChannelProxy* daemon_channel_; | 114   IPC::ChannelProxy* daemon_channel_; | 
| 110 | 115 | 
| 111   // List of DesktopEnvironment instances we've told the daemon process about. | 116   // List of DesktopEnvironment instances we've told the daemon process about. | 
| 112   typedef std::map<int, scoped_refptr<DesktopSessionProxy> > | 117   typedef std::map<int, scoped_refptr<DesktopSessionProxy> > | 
| 113       ActiveConnectionsList; | 118       ActiveConnectionsList; | 
| 114   ActiveConnectionsList active_connections_; | 119   ActiveConnectionsList active_connections_; | 
| 115 | 120 | 
| 116   // Factory for weak pointers to DesktopSessionConnector interface. | 121   // Factory for weak pointers to DesktopSessionConnector interface. | 
| 117   base::WeakPtrFactory<DesktopSessionConnector> connector_factory_; | 122   base::WeakPtrFactory<DesktopSessionConnector> connector_factory_; | 
| 118 | 123 | 
| 119   // Next desktop session ID. IDs are allocated sequentially starting from 0. | 124   // Next desktop session ID. IDs are allocated sequentially starting from 0. | 
| 120   // 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 | 
| 121   // allocated every second. | 126   // allocated every second. | 
| 122   int next_id_; | 127   int next_id_; | 
| 123 | 128 | 
| 124   DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory); | 129   DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory); | 
| 125 }; | 130 }; | 
| 126 | 131 | 
| 127 }  // namespace remoting | 132 }  // namespace remoting | 
| 128 | 133 | 
| 129 #endif  // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ | 134 #endif  // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ | 
| OLD | NEW | 
|---|