summaryrefslogtreecommitdiffstats
path: root/remoting/host/daemon_process.cc
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/host/daemon_process.cc')
-rw-r--r--remoting/host/daemon_process.cc61
1 files changed, 46 insertions, 15 deletions
diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc
index 2a08284..607fca7 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& serialized_config) {
+ if (serialized_config_ != serialized_config) {
+ serialized_config_ = serialized_config;
+ Send(new ChromotingDaemonNetworkMsg_Configuration(serialized_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(serialized_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();
}