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..66347ea3e35a7c833a8a21a245135bf38a0bd8d2 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" |
| @@ -123,12 +124,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_->ConfigUpdated(); |
|
Sergey Ulanov
2012/04/16 23:36:24
It might be better to wait for a couple of seconds
simonmorris
2012/04/17 00:04:55
Done, but please check the code.
|
| + } |
| + 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 +182,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 +388,7 @@ class HostProcess : public OAuthClient::Delegate { |
| scoped_ptr<policy_hack::NatPolicy> nat_policy_; |
| bool allow_nat_traversal_; |
| + scoped_ptr<base::files::FilePathWatcher> config_watcher_; |
| bool restarting_; |