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_DESKTOP_SESSION_AGENT_H_ |
| 6 #define REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ipc/ipc_listener.h" |
| 14 #include "ipc/ipc_platform_file.h" |
| 15 |
| 16 namespace IPC { |
| 17 class ChannelProxy; |
| 18 class Message; |
| 19 } // namespace IPC |
| 20 |
| 21 namespace remoting { |
| 22 |
| 23 class AutoThreadTaskRunner; |
| 24 |
| 25 // Provides screen/audio capturing and input injection services for |
| 26 // the network process. |
| 27 class DesktopSessionAgent : public IPC::Listener { |
| 28 public: |
| 29 static scoped_ptr<DesktopSessionAgent> Create( |
| 30 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 31 scoped_refptr<AutoThreadTaskRunner> io_task_runner); |
| 32 |
| 33 virtual ~DesktopSessionAgent(); |
| 34 |
| 35 // IPC::Listener implementation. |
| 36 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 37 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 38 virtual void OnChannelError() OVERRIDE; |
| 39 |
| 40 // Creates the screen/audio recorders, input stubs and the IPC channel to be |
| 41 // used to access them. Returns a handle of the client end of the IPC channel |
| 42 // pipe to be forwarder to the corresponding desktop environment. |
| 43 bool Start(const base::Closure& done_task, |
| 44 IPC::PlatformFileForTransit* desktop_pipe_out); |
| 45 |
| 46 protected: |
| 47 DesktopSessionAgent( |
| 48 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 49 scoped_refptr<AutoThreadTaskRunner> io_task_runner); |
| 50 |
| 51 // Creates a pre-connected IPC channel to be used to access the screen/audio |
| 52 // recorders and input stubs. |
| 53 virtual bool DoCreateNetworkChannel( |
| 54 IPC::PlatformFileForTransit* client_out, |
| 55 scoped_ptr<IPC::ChannelProxy>* server_out) = 0; |
| 56 |
| 57 scoped_refptr<AutoThreadTaskRunner> caller_task_runner() const { |
| 58 return caller_task_runner_; |
| 59 } |
| 60 |
| 61 scoped_refptr<AutoThreadTaskRunner> io_task_runner() const { |
| 62 return io_task_runner_; |
| 63 } |
| 64 |
| 65 private: |
| 66 // Task runner on which public methods of this class should be called. |
| 67 scoped_refptr<AutoThreadTaskRunner> caller_task_runner_; |
| 68 |
| 69 // Message loop used by the IPC channel. |
| 70 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; |
| 71 |
| 72 // Run on |caller_task_runner_| to notify the caller that |this| has been |
| 73 // stopped. |
| 74 base::Closure done_task_; |
| 75 |
| 76 // IPC channel connecting the desktop process with the network process. |
| 77 scoped_ptr<IPC::ChannelProxy> network_channel_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent); |
| 80 }; |
| 81 |
| 82 } // namespace remoting |
| 83 |
| 84 #endif // REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ |
OLD | NEW |