summaryrefslogtreecommitdiffstats
path: root/remoting/host/remoting_me2me_host.cc
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 17:46:00 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 17:46:00 +0000
commit1dda5abef8ef78f0579b3ea27458d33cca2cc78f (patch)
treef63201090c569d7e13b7912f4b7fa0e8efa828b0 /remoting/host/remoting_me2me_host.cc
parente965247e6a0755a90ec20601e0cb06b62d5fbc86 (diff)
downloadchromium_src-1dda5abef8ef78f0579b3ea27458d33cca2cc78f.zip
chromium_src-1dda5abef8ef78f0579b3ea27458d33cca2cc78f.tar.gz
chromium_src-1dda5abef8ef78f0579b3ea27458d33cca2cc78f.tar.bz2
[Chromoting] Implement UpdateConfig() for the Windows host.
BUG=121539 Review URL: http://codereview.chromium.org/10103010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132598 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/remoting_me2me_host.cc')
-rw-r--r--remoting/host/remoting_me2me_host.cc42
1 files changed, 39 insertions, 3 deletions
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index cb81bf8..ad8c175 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"
@@ -83,6 +84,9 @@ class HostProcess : public OAuthClient::Delegate {
new ChromotingHostContext(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) {
@@ -118,12 +122,42 @@ 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 {
+ // Call ConfigUpdated after a short delay, so that this object won't
+ // try to read the updated configuration file before it has been
+ // completely written.
+ // If the writer moves the new configuration file into place atomically,
+ // this delay may not be necessary.
+ 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(
@@ -151,7 +185,7 @@ class HostProcess : public OAuthClient::Delegate {
StartWatchingNatPolicy();
}
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_WIN)
context_->file_message_loop()->PostTask(
FROM_HERE,
base::Bind(&HostProcess::ListenForConfigChanges,
@@ -356,6 +390,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_;