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

Unified Diff: remoting/host/remoting_me2me_host.cc

Issue 10103010: [Chromoting] Implement UpdateConfig() for the Windows host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix syntax. Created 8 years, 8 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/remoting_me2me_host.cc
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index f380056afb27e437f1d868d7faff9107857b3db9..f05aa0e6b20a7a3620e0b3513700c33732fcb45d 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -16,6 +16,7 @@
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/files/file_path_watcher.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
@@ -88,6 +89,9 @@ class HostProcess : public OAuthClient::Delegate {
message_loop_.message_loop_proxy()));
context_->Start();
network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
+ config_updated_timer_.reset(new base::DelayTimer<HostProcess>(
Sergey Ulanov 2012/04/17 05:42:18 Add a comment here or in OnFilePathChanged() to ex
simonmorris 2012/04/17 15:55:47 Done.
+ FROM_HERE, base::TimeDelta::FromSeconds(2), this,
+ &HostProcess::ConfigUpdated));
}
void InitWithCommandLine(const CommandLine* cmd_line) {
@@ -123,12 +127,37 @@ class HostProcess : public OAuthClient::Delegate {
}
}
-#if defined(OS_MACOSX)
+#if defined(OS_WIN)
+ class ConfigChangedDelegate : public base::files::FilePathWatcher::Delegate {
+ public:
+ ConfigChangedDelegate(HostProcess* host_process) :
+ host_process_(host_process) {
+ }
+ void OnFilePathChanged(const FilePath& path) OVERRIDE {
+ host_process_->config_updated_timer_->Reset();
+ }
+ void OnFilePathError(const FilePath& path) OVERRIDE {
+ }
+ private:
+ HostProcess* host_process_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConfigChangedDelegate);
+ };
+#endif // defined(OS_WIN)
+
void ListenForConfigChanges() {
+#if defined(OS_MACOSX)
remoting::RegisterHupSignalHandler(
base::Bind(&HostProcess::ConfigUpdated, base::Unretained(this)));
- }
+#elif defined(OS_WIN)
+ scoped_refptr<base::files::FilePathWatcher::Delegate> delegate(
+ new ConfigChangedDelegate(this));
+ config_watcher_.reset(new base::files::FilePathWatcher());
+ if (!config_watcher_->Watch(host_config_path_, delegate)) {
+ LOG(ERROR) << "Couldn't watch file " << host_config_path_.value();
+ }
#endif
+ }
void CreateAuthenticatorFactory() {
scoped_ptr<protocol::AuthenticatorFactory> factory(
@@ -156,7 +185,7 @@ class HostProcess : public OAuthClient::Delegate {
StartWatchingNatPolicy();
}
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_WIN)
file_io_thread_.message_loop_proxy()->PostTask(
FROM_HERE,
base::Bind(&HostProcess::ListenForConfigChanges,
@@ -362,6 +391,8 @@ class HostProcess : public OAuthClient::Delegate {
scoped_ptr<policy_hack::NatPolicy> nat_policy_;
bool allow_nat_traversal_;
+ scoped_ptr<base::files::FilePathWatcher> config_watcher_;
+ scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_;
bool restarting_;

Powered by Google App Engine
This is Rietveld 408576698