diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-05 19:58:36 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-05 19:58:36 +0000 |
commit | df338b7db4dfebd184886fec55db969305c94f07 (patch) | |
tree | 8e0184e81556899615ffac2120efe0ea563a1cce /remoting/host/daemon_process.cc | |
parent | e2206627c1f4f26425b7ba51a21e8d021956bea1 (diff) | |
download | chromium_src-df338b7db4dfebd184886fec55db969305c94f07.zip chromium_src-df338b7db4dfebd184886fec55db969305c94f07.tar.gz chromium_src-df338b7db4dfebd184886fec55db969305c94f07.tar.bz2 |
[Chromoting] The daemon process now starts the networking process and passes the host configuration (and updates) over the IPC channel.
This CL also switches to FilePathWatcher (to detect the configuration file changes) on all platforms.
BUG=123696,134694
Review URL: https://chromiumcodereview.appspot.com/10855249
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154999 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/daemon_process.cc')
-rw-r--r-- | remoting/host/daemon_process.cc | 61 |
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(); } |