Chromium Code Reviews| 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..5120024cc8a1c726977a9da1bd060449830936ef 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>( |
| + 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_; |
|
alexeypa (please no reviews)
2012/04/17 00:10:34
There should be a space between > >. Otherwise it
simonmorris
2012/04/17 00:34:02
Done.
|
| bool restarting_; |