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_DAEMON_PROCESS_H_ |
| 6 #define REMOTING_HOST_DAEMON_PROCESS_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ipc/ipc_channel.h" |
| 13 #include "ipc/ipc_channel_proxy.h" |
| 14 #include "remoting/base/stoppable.h" |
| 15 |
| 16 namespace base { |
| 17 class SingleThreadTaskRunner; |
| 18 class Thread; |
| 19 } // namespace base |
| 20 |
| 21 namespace IPC { |
| 22 class Message; |
| 23 } // namespace IPC |
| 24 |
| 25 namespace remoting { |
| 26 |
| 27 // This class implements core of the daemon process. It manages the networking |
| 28 // process running at lower privileges and maintains the list of virtual |
| 29 // terminals. |
| 30 class DaemonProcess : public Stoppable, public IPC::Listener { |
| 31 public: |
| 32 virtual ~DaemonProcess(); |
| 33 |
| 34 // Creates a platform-specific implementation of the daemon process object. |
| 35 static scoped_ptr<DaemonProcess> Create( |
| 36 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 37 const base::Closure& stopped_callback); |
| 38 |
| 39 // IPC::Listener implementation. |
| 40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 41 |
| 42 protected: |
| 43 DaemonProcess(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 44 const base::Closure& stopped_callback); |
| 45 |
| 46 // Reads the host configuration and launches the networking process. |
| 47 void Init(); |
| 48 |
| 49 // Stoppable implementation. |
| 50 virtual void DoStop() OVERRIDE; |
| 51 |
| 52 // Launches the network process and establishes an IPC channel with it. |
| 53 virtual bool LaunchNetworkProcess() = 0; |
| 54 |
| 55 private: |
| 56 // The main task runner. Typically it is the UI message loop. |
| 57 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 58 |
| 59 // A dedicated thread for handling IPC requests. |
| 60 scoped_ptr<base::Thread> ipc_thread_; |
| 61 |
| 62 // The IPC channel connecting the daemon process to the networking process. |
| 63 scoped_ptr<IPC::ChannelProxy> network_process_channel_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(DaemonProcess); |
| 66 }; |
| 67 |
| 68 } // namespace remoting |
| 69 |
| 70 #endif // REMOTING_HOST_DAEMON_PROCESS_H_ |
OLD | NEW |