| 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" |
| 14 #include "base/memory/weak_ptr.h" |
| 12 #include "ipc/ipc_platform_file.h" | 15 #include "ipc/ipc_platform_file.h" |
| 13 #include "remoting/host/desktop_environment.h" | 16 #include "remoting/host/desktop_environment.h" |
| 14 | 17 |
| 15 namespace base { | 18 namespace base { |
| 16 class SingleThreadTaskRunner; | 19 class SingleThreadTaskRunner; |
| 17 } // base | 20 } // base |
| 18 | 21 |
| 19 namespace remoting { | 22 namespace remoting { |
| 20 | 23 |
| 21 class DesktopSessionConnector; | 24 class DesktopSessionConnector; |
| 22 class DesktopSessionProxy; | 25 class DesktopSessionProxy; |
| 23 | 26 |
| 24 // A variant of desktop environment integrating with the desktop by means of | 27 // A variant of desktop environment integrating with the desktop by means of |
| 25 // a helper process and talking to that process via IPC. | 28 // a helper process and talking to that process via IPC. |
| 26 class IpcDesktopEnvironment : public DesktopEnvironment { | 29 class IpcDesktopEnvironment : public DesktopEnvironment { |
| 27 public: | 30 public: |
| 28 // |desktop_session_connector| is used to bind the IpcDesktopEnvironment to | 31 // |desktop_session_connector| is used to bind DesktopSessionProxy to |
| 29 // a desktop session, to be notified with a new IPC channel every time | 32 // a desktop session, to be notified every time the desktop process is |
| 30 // the desktop process is changed. |desktop_session_connector| must outlive | 33 // restarted. |
| 31 // |this|. |client| specifies the client session owning |this|. | |
| 32 IpcDesktopEnvironment( | 34 IpcDesktopEnvironment( |
| 33 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 35 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
| 34 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 36 const std::string& client_jid, |
| 35 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 37 const base::Closure& disconnect_callback, |
| 36 DesktopSessionConnector* desktop_session_connector, | 38 base::WeakPtr<DesktopSessionConnector> desktop_session_connector); |
| 37 scoped_refptr<DesktopSessionProxy> desktop_session_proxy); | |
| 38 virtual ~IpcDesktopEnvironment(); | 39 virtual ~IpcDesktopEnvironment(); |
| 39 | 40 |
| 40 virtual void Start( | 41 // protocol::ClipboardStub implementation. |
| 41 scoped_ptr<protocol::ClipboardStub> client_clipboard, | 42 virtual void InjectClipboardEvent( |
| 42 const std::string& client_jid, | 43 const protocol::ClipboardEvent& event) OVERRIDE; |
| 43 const base::Closure& disconnect_callback) OVERRIDE; | 44 |
| 45 // protocol::InputStub implementation. |
| 46 virtual void InjectKeyEvent(const protocol::KeyEvent& event) OVERRIDE; |
| 47 virtual void InjectMouseEvent(const protocol::MouseEvent& event) OVERRIDE; |
| 48 |
| 49 // DesktopEnvironment implementation. |
| 50 virtual void StartAudio( |
| 51 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 52 scoped_ptr<AudioEncoder> audio_encoder, |
| 53 protocol::AudioStub* audio_stub) OVERRIDE; |
| 54 virtual void PauseAudio(bool pause) OVERRIDE; |
| 55 virtual void StartInput( |
| 56 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 57 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 58 protocol::ClipboardStub* clipboard_stub) OVERRIDE; |
| 59 virtual void StartVideo( |
| 60 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 61 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner, |
| 62 scoped_ptr<VideoEncoder> video_encoder, |
| 63 protocol::CursorShapeStub* cursor_shape_stub, |
| 64 protocol::VideoStub* video_stub) OVERRIDE; |
| 65 virtual SkISize GetScreenSize() const OVERRIDE; |
| 66 virtual void PauseVideo(bool pause) OVERRIDE; |
| 67 virtual void UpdateSequenceNumber(int64 sequence_number) OVERRIDE; |
| 44 | 68 |
| 45 private: | 69 private: |
| 46 // Used for IPC I/O. | 70 // Binds DesktopSessionProxy to a desktop session if it is not bound already. |
| 47 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 71 void RegisterDesktopSessionProxy(); |
| 48 | 72 |
| 49 DesktopSessionConnector* desktop_session_connector_; | 73 // Task runner on which public methods of this class should be called. |
| 74 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
| 75 |
| 76 // True if |desktop_session_proxy_| has been connected to a desktop session. |
| 77 bool connected_; |
| 78 |
| 79 // Used to bind DesktopSessionProxy to a desktop session, to be notified every |
| 80 // time the desktop process is restarted. |
| 81 base::WeakPtr<DesktopSessionConnector> desktop_session_connector_; |
| 50 | 82 |
| 51 scoped_refptr<DesktopSessionProxy> desktop_session_proxy_; | 83 scoped_refptr<DesktopSessionProxy> desktop_session_proxy_; |
| 52 | 84 |
| 53 // True if |this| has been connected to a desktop session. | |
| 54 bool connected_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment); | 85 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment); |
| 57 }; | 86 }; |
| 58 | 87 |
| 59 } // namespace remoting | 88 } // namespace remoting |
| 60 | 89 |
| 61 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ | 90 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ |
| OLD | NEW |