Chromium Code Reviews| Index: remoting/host/daemon_process.h |
| diff --git a/remoting/host/daemon_process.h b/remoting/host/daemon_process.h |
| index ed5f4cba1fc4a37598baa350fe6ec8f124ff1885..eba8fb51e4659c764dc51e087e5b46c0325061bc 100644 |
| --- a/remoting/host/daemon_process.h |
| +++ b/remoting/host/daemon_process.h |
| @@ -12,22 +12,24 @@ |
| #include "ipc/ipc_channel.h" |
| #include "ipc/ipc_channel_proxy.h" |
| #include "remoting/base/stoppable.h" |
| +#include "remoting/host/config_file_watcher.h" |
| +#include "remoting/host/worker_process_delegate.h" |
| + |
| +class FilePath; |
| namespace base { |
| class SingleThreadTaskRunner; |
| -class Thread; |
| } // namespace base |
| -namespace IPC { |
| -class Message; |
| -} // namespace IPC |
| - |
| namespace remoting { |
| // This class implements core of the daemon process. It manages the networking |
| // process running at lower privileges and maintains the list of virtual |
| // terminals. |
| -class DaemonProcess : public Stoppable, public IPC::Listener { |
| +class DaemonProcess |
| + : public Stoppable, |
| + public ConfigFileWatcher::Delegate, |
| + public WorkerProcessDelegate { |
| public: |
| virtual ~DaemonProcess(); |
| @@ -37,32 +39,83 @@ class DaemonProcess : public Stoppable, public IPC::Listener { |
| scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| const base::Closure& stopped_callback); |
| - // IPC::Listener implementation. |
| + // ConfigFileWatcher::Delegate |
| + virtual void OnConfigUpdated(const std::string& config) OVERRIDE; |
| + virtual void OnConfigWatcherError() OVERRIDE; |
| + |
| + // WorkerProcessDelegate implementation. |
| + virtual void OnChannelConnected() OVERRIDE; |
| virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| + // Sends an IPC message to the worker process. The message will be dropped |
| + // unless the network process is connected over the IPC channel. |
| + virtual void Send(IPC::Message* message) = 0; |
| + |
| protected: |
| DaemonProcess(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| const base::Closure& stopped_callback); |
| // Reads the host configuration and launches the networking process. |
| - void Init(); |
| + void Initialize(); |
| // Stoppable implementation. |
| virtual void DoStop() OVERRIDE; |
| // Launches the network process and establishes an IPC channel with it. |
| - virtual bool LaunchNetworkProcess() = 0; |
| + virtual void LaunchNetworkProcess() = 0; |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner() { |
| + return main_task_runner_; |
| + } |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner() { |
| + return io_task_runner_; |
| + } |
| private: |
| + // Called every time the host configuration file is updated. |
| + void ConfigUpdated(const FilePath& path, bool error); |
|
Wez
2012/08/30 20:36:04
You don't need this, or the next few methods, I do
alexeypa (please no reviews)
2012/08/30 23:15:13
Yes. I forgot to remove them.
|
| + |
| + // Reads the configuration file and passes it to the |main_task_runner_| |
| + // thread. |
| + void ReloadConfig(); |
| + |
| + // Sends |config| to the network process. |
| + void SendConfig(const std::string& config); |
| + |
| + // Starts monitoring the configuration file updates. |
| + void StartConfigWatcher(); |
| + |
| + // Stops monitoring the configuration file updates. |
| + void StopConfigWatcher(); |
| + |
| + // Notifies the |main_task_runner_| thread that the configuration file watcher |
| + // has been fully stopped. |
| + void StopConfigWatcherCompleted(); |
| + |
| + // The configuration file contents. |
| + std::string config_; |
| + |
| + scoped_ptr<ConfigFileWatcher> config_watcher_; |
| + |
| + enum ConfigWatcherState { |
| + kConfigWatcherUninitialized, |
| + kConfigWatcherRunning, |
| + kConfigWatcherStopping, |
| + kConfigWatcherStopped |
| + }; |
| + |
| + ConfigWatcherState config_watcher_state_; |
| + |
| // The main task runner. Typically it is the UI message loop. |
| scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| // Handles IPC and background I/O tasks. |
| scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| - // The IPC channel connecting the daemon process to the networking process. |
| - scoped_ptr<IPC::ChannelProxy> network_process_channel_; |
| + // WeakPtr used to avoid tasks accessing |this| after it is deleted. |
| + base::WeakPtrFactory<DaemonProcess> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(DaemonProcess); |
| }; |