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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "ipc/ipc_listener.h" |
| 12 #include "ipc/ipc_platform_file.h" |
11 #include "remoting/host/desktop_environment.h" | 13 #include "remoting/host/desktop_environment.h" |
12 | 14 |
13 namespace base { | 15 namespace base { |
14 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
15 } // base | 17 } // base |
16 | 18 |
| 19 namespace IPC { |
| 20 class ChannelProxy; |
| 21 } // base |
| 22 |
17 namespace remoting { | 23 namespace remoting { |
18 | 24 |
19 class ClientSession; | 25 class ClientSession; |
20 class DesktopSessionConnector; | 26 class DesktopSessionConnector; |
21 | 27 |
22 // A variant of desktop environment integrating with the desktop by means of | 28 // A variant of desktop environment integrating with the desktop by means of |
23 // a helper process and talking to that process via IPC. | 29 // a helper process and talking to that process via IPC. |
24 class IpcDesktopEnvironment : public DesktopEnvironment { | 30 class IpcDesktopEnvironment : public DesktopEnvironment, public IPC::Listener { |
25 public: | 31 public: |
26 // |desktop_session_connector| is used to bind the IpcDesktopEnvironment to | 32 // |desktop_session_connector| is used to bind the IpcDesktopEnvironment to |
27 // a desktop session, to be notified with a new IPC channel every time | 33 // a desktop session, to be notified with a new IPC channel every time |
28 // the desktop process is changed. |desktop_session_connector| must outlive | 34 // the desktop process is changed. |desktop_session_connector| must outlive |
29 // |this|. |client| specifies the client session owning |this|. | 35 // |this|. |client| specifies the client session owning |this|. |
30 IpcDesktopEnvironment( | 36 IpcDesktopEnvironment( |
31 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 37 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 38 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
32 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 39 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
33 DesktopSessionConnector* desktop_session_connector, | 40 DesktopSessionConnector* desktop_session_connector, |
34 ClientSession* client); | 41 ClientSession* client); |
35 virtual ~IpcDesktopEnvironment(); | 42 virtual ~IpcDesktopEnvironment(); |
36 | 43 |
| 44 // IPC::Listener implementation. |
| 45 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 46 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 47 virtual void OnChannelError() OVERRIDE; |
| 48 |
37 virtual void Start( | 49 virtual void Start( |
38 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; | 50 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; |
39 | 51 |
40 // Disconnects the client session that owns |this|. | 52 // Disconnects the client session that owns |this|. |
41 void DisconnectClient(); | 53 void DisconnectClient(); |
42 | 54 |
| 55 // Notifies |this| that it is now attached to a desktop integration process. |
| 56 // |desktop_process| specifies the process handle. |desktop_pipe| is |
| 57 // the client end of the pipe opened by the desktop process. |
| 58 void OnDesktopSessionAgentAttached( |
| 59 IPC::PlatformFileForTransit desktop_process, |
| 60 IPC::PlatformFileForTransit desktop_pipe); |
| 61 |
43 private: | 62 private: |
| 63 // Used for IPC I/O. |
| 64 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 65 |
44 DesktopSessionConnector* desktop_session_connector_; | 66 DesktopSessionConnector* desktop_session_connector_; |
45 | 67 |
46 // Specifies the client session that owns |this|. | 68 // Specifies the client session that owns |this|. |
47 ClientSession* client_; | 69 ClientSession* client_; |
48 | 70 |
49 // True if |this| has been connected to a desktop session. | 71 // True if |this| has been connected to a desktop session. |
50 bool connected_; | 72 bool connected_; |
51 | 73 |
| 74 // Connects |this| with the desktop process. |
| 75 scoped_ptr<IPC::ChannelProxy> desktop_channel_; |
| 76 |
52 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment); | 77 DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment); |
53 }; | 78 }; |
54 | 79 |
55 } // namespace remoting | 80 } // namespace remoting |
56 | 81 |
57 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ | 82 #endif // REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_ |
OLD | NEW |