| Index: remoting/host/daemon_process.cc
|
| diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc
|
| index 2a08284eb4dae13847613ae9b7a590961b3e75ee..9b7f585e03d0ca621a255b0e22a3d76c6387f4d4 100644
|
| --- a/remoting/host/daemon_process.cc
|
| +++ b/remoting/host/daemon_process.cc
|
| @@ -6,22 +6,41 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| +#include "base/command_line.h"
|
| +#include "base/file_path.h"
|
| +#include "base/file_util.h"
|
| #include "base/single_thread_task_runner.h"
|
| -#include "base/threading/thread.h"
|
| +#include "remoting/host/branding.h"
|
| +#include "remoting/host/chromoting_messages.h"
|
|
|
| -namespace {
|
| +namespace remoting {
|
|
|
| -const char kIpcThreadName[] = "Daemon process IPC";
|
| +DaemonProcess::~DaemonProcess() {
|
| + CHECK(!config_watcher_.get());
|
| +}
|
|
|
| -} // namespace
|
| +void DaemonProcess::OnConfigUpdated(const std::string& config) {
|
| + if (config_ != config) {
|
| + config_ = config;
|
| + Send(new ChromotingDaemonNetworkMsg_Configuration(config_));
|
| + }
|
| +}
|
|
|
| -namespace remoting {
|
| +void DaemonProcess::OnConfigWatcherError() {
|
| + Stop();
|
| +}
|
|
|
| -DaemonProcess::~DaemonProcess() {
|
| +void DaemonProcess::OnChannelConnected() {
|
| + DCHECK(main_task_runner()->BelongsToCurrentThread());
|
| +
|
| + // Send the configuration to the network process.
|
| + Send(new ChromotingDaemonNetworkMsg_Configuration(config_));
|
| }
|
|
|
| bool DaemonProcess::OnMessageReceived(const IPC::Message& message) {
|
| - return true;
|
| + DCHECK(main_task_runner()->BelongsToCurrentThread());
|
| +
|
| + return false;
|
| }
|
|
|
| DaemonProcess::DaemonProcess(
|
| @@ -34,22 +53,34 @@ DaemonProcess::DaemonProcess(
|
| // Initialize on the same thread that will be used for shutting down.
|
| main_task_runner_->PostTask(
|
| FROM_HERE,
|
| - base::Bind(&DaemonProcess::Init, base::Unretained(this)));
|
| + base::Bind(&DaemonProcess::Initialize, base::Unretained(this)));
|
| }
|
|
|
| -void DaemonProcess::Init() {
|
| - DCHECK(main_task_runner_->BelongsToCurrentThread());
|
| +void DaemonProcess::Initialize() {
|
| + DCHECK(main_task_runner()->BelongsToCurrentThread());
|
|
|
| - if (!LaunchNetworkProcess()) {
|
| - LOG(ERROR) << "Failed to launch the networking process.";
|
| - Stop();
|
| - return;
|
| + // Get the name of the host configuration file.
|
| + FilePath default_config_dir = remoting::GetConfigDir();
|
| + FilePath config_path = default_config_dir.Append(kDefaultHostConfigFile);
|
| + const CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| + if (command_line->HasSwitch(kHostConfigSwitchName)) {
|
| + config_path = command_line->GetSwitchValuePath(kHostConfigSwitchName);
|
| }
|
| +
|
| + // Start watching the host configuration file.
|
| + config_watcher_.reset(new ConfigFileWatcher(main_task_runner(),
|
| + io_task_runner(),
|
| + this));
|
| + config_watcher_->Watch(config_path);
|
| +
|
| + // Launch the process.
|
| + LaunchNetworkProcess();
|
| }
|
|
|
| void DaemonProcess::DoStop() {
|
| - DCHECK(main_task_runner_->BelongsToCurrentThread());
|
| + DCHECK(main_task_runner()->BelongsToCurrentThread());
|
|
|
| + config_watcher_.reset();
|
| CompleteStopping();
|
| }
|
|
|
|
|