Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: remoting/host/daemon_process.cc

Issue 10855249: [Chromoting] The daemon process now starts the networking process and passes the host configuration… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback and rebased on top of https://chromiumcodereview.appspot.com/10829467/ Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/daemon_process.cc
diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc
index 2a08284eb4dae13847613ae9b7a590961b3e75ee..354d5abb1183c91a83ca66e829b8978f656e9a09 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(
@@ -30,27 +49,54 @@ DaemonProcess::DaemonProcess(
const base::Closure& stopped_callback)
: Stoppable(main_task_runner, stopped_callback),
main_task_runner_(main_task_runner),
- io_task_runner_(io_task_runner) {
+ io_task_runner_(io_task_runner),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
// 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 DaemonConfigWatcher(main_task_runner(),
+ io_task_runner(),
+ weak_factory_.GetWeakPtr()));
+ config_watcher_->Watch(config_path);
+
+ // Launch the process.
+ LaunchNetworkProcess();
}
void DaemonProcess::DoStop() {
- DCHECK(main_task_runner_->BelongsToCurrentThread());
+ DCHECK(main_task_runner()->BelongsToCurrentThread());
+
+ weak_factory_.InvalidateWeakPtrs();
+ if (config_watcher_.get()) {
+ DaemonConfigWatcher* config_watcher = config_watcher_.get();
Wez 2012/08/24 22:20:38 Why do you need this?
alexeypa (please no reviews) 2012/08/27 23:16:41 I wasn't sure that -> will be evaluated before con
+ config_watcher->Stop(config_watcher_.Pass());
+ }
CompleteStopping();
}
+void DaemonProcess::SendConfig(const std::string& config) {
+ DCHECK(main_task_runner()->BelongsToCurrentThread());
+
+ if (config_ != config) {
+ config_ = config;
+ Send(new ChromotingDaemonNetworkMsg_Configuration(config_));
+ }
+}
+
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698