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..ea006df788f03e403f763257877ca782a836e618 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,35 @@ class HostProcess : public OAuthClient::Delegate { |
| } |
| } |
| -#if defined(OS_MACOSX) |
| + class ConfigChangedDelegate : public base::files::FilePathWatcher::Delegate { |
|
Jamie
2012/04/16 22:26:48
Neat!
|
| + public: |
| + ConfigChangedDelegate(HostProcess* host_process) : |
| + host_process_(host_process) { |
| + } |
| + void OnFilePathChanged(const FilePath& path) OVERRIDE { |
| + host_process_->ConfigUpdated(); |
| + } |
| + void OnFilePathError(const FilePath& path) OVERRIDE { |
| + } |
| + private: |
| + HostProcess* host_process_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ConfigChangedDelegate); |
| + }; |
| + |
| void ListenForConfigChanges() { |
| +#if defined(OS_MACOSX) |
| remoting::RegisterHupSignalHandler( |
| base::Bind(&HostProcess::ConfigUpdated, base::Unretained(this))); |
| - } |
| +#else |
| + 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 +180,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 +386,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_; |