| 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 <string> |
| 9 |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "ipc/ipc_platform_file.h" | 14 #include "base/memory/weak_ptr.h" |
| 13 #include "remoting/host/desktop_environment.h" | 15 #include "remoting/host/desktop_environment.h" |
| 14 | 16 |
| 15 namespace base { | 17 namespace base { |
| 16 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
| 17 } // base | 19 } // base |
| 18 | 20 |
| 19 namespace remoting { | 21 namespace remoting { |
| 20 | 22 |
| 21 class DesktopSessionConnector; | 23 class DesktopSessionConnector; |
| 22 class DesktopSessionProxy; | 24 class DesktopSessionProxy; |
| 23 | 25 |
| 24 // A variant of desktop environment integrating with the desktop by means of | 26 // A variant of desktop environment integrating with the desktop by means of |
| 25 // a helper process and talking to that process via IPC. | 27 // a helper process and talking to that process via IPC. |
| 26 class IpcDesktopEnvironment : public DesktopEnvironment { | 28 class IpcDesktopEnvironment : public DesktopEnvironment { |
| 27 public: | 29 public: |
| 28 // |desktop_session_connector| is used to bind the IpcDesktopEnvironment to | 30 // |desktop_session_connector| is used to bind DesktopSessionProxy to |
| 29 // a desktop session, to be notified with a new IPC channel every time | 31 // a desktop session, to be notified every time the desktop process is |
| 30 // the desktop process is changed. |desktop_session_connector| must outlive | 32 // restarted. |
| 31 // |this|. |client| specifies the client session owning |this|. | |
| 32 IpcDesktopEnvironment( | 33 IpcDesktopEnvironment( |
| 33 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 34 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 34 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 35 const std::string& client_jid, |
| 35 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 36 const base::Closure& disconnect_callback, |
| 36 DesktopSessionConnector* desktop_session_connector, | 37 base::WeakPtr<DesktopSessionConnector> desktop_session_connector); |
| 37 scoped_refptr<DesktopSessionProxy> desktop_session_proxy); | |
| 38 virtual ~IpcDesktopEnvironment(); | 38 virtual ~IpcDesktopEnvironment(); |
| 39 | 39 |
| 40 virtual void Start( | 40 // DesktopEnvironment implementation. |
| 41 scoped_ptr<protocol::ClipboardStub> client_clipboard, | 41 virtual scoped_ptr<AudioCapturer> CreateAudioCapturer( |
| 42 const std::string& client_jid, | 42 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner) OVERRIDE; |
| 43 const base::Closure& disconnect_callback) OVERRIDE; | 43 virtual scoped_ptr<EventExecutor> CreateEventExecutor( |
| 44 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 45 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) OVERRIDE; |
| 46 virtual scoped_ptr<VideoFrameCapturer> CreateVideoCapturer( |
| 47 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 48 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) OVERRIDE; |
| 44 | 49 |
| 45 private: | 50 private: |
| 46 // Used for IPC I/O. | 51 // Binds DesktopSessionProxy to a desktop session if it is not bound already. |
| 47 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 52 void RegisterDesktopSessionProxy(); |
| 48 | 53 |
| 49 DesktopSessionConnector* desktop_session_connector_; | 54 // Task runner on which public methods of this class should be called. |
| 55 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
| 56 |
| 57 // True if |desktop_session_proxy_| has been connected to a desktop session. |
| 58 bool connected_; |
| 59 |
| 60 // Used to bind DesktopSessionProxy to a desktop session, to be notified every |
| 61 // time the desktop process is restarted. |
| 62 base::WeakPtr<DesktopSessionConnector> desktop_session_connector_; |
| 50 | 63 |
| 51 scoped_refptr<DesktopSessionProxy> desktop_session_proxy_; | 64 scoped_refptr<DesktopSessionProxy> desktop_session_proxy_; |
| 52 | 65 |
| 53 // True if |this| has been connected to a desktop session. | |
| 54 bool connected_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment); | 66 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment); |
| 57 }; | 67 }; |
| 58 | 68 |
| 59 } // namespace remoting | 69 } // namespace remoting |
| 60 | 70 |
| 61 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ | 71 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ |
| OLD | NEW |