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

Unified Diff: remoting/host/remoting_me2me_host.cc

Issue 10804040: [Chromoting] Refactor the host policy watcher so that policies can easily be added. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for Windows. Created 8 years, 5 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
« no previous file with comments | « remoting/host/policy_hack/policy_watcher_win.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/remoting_me2me_host.cc
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc
index 848d5bb63a764b7ee398dba92501594319d76e34..18822ea05c0d8a4ca56058b52837a73db4b35566 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -41,7 +41,7 @@
#include "remoting/host/json_host_config.h"
#include "remoting/host/log_to_server.h"
#include "remoting/host/network_settings.h"
-#include "remoting/host/policy_hack/nat_policy.h"
+#include "remoting/host/policy_hack/policy_watcher.h"
#include "remoting/host/session_manager_factory.h"
#include "remoting/host/signaling_connector.h"
#include "remoting/host/usage_stats_consent.h"
@@ -213,7 +213,7 @@ class HostProcess
host_user_interface_.reset(new HostUserInterface(context_.get()));
#endif
- StartWatchingNatPolicy();
+ StartWatchingPolicy();
#if defined(OS_MACOSX) || defined(OS_WIN)
context_->file_task_runner()->PostTask(
@@ -228,9 +228,9 @@ class HostProcess
#endif
base::WaitableEvent done_event(true, false);
- nat_policy_->StopWatching(&done_event);
+ policy_watcher_->StopWatching(&done_event);
done_event.Wait();
- nat_policy_.reset();
+ policy_watcher_.reset();
return exit_code_;
}
@@ -242,11 +242,11 @@ class HostProcess
}
private:
- void StartWatchingNatPolicy() {
- nat_policy_.reset(
- policy_hack::NatPolicy::Create(context_->file_task_runner()));
- nat_policy_->StartWatching(
- base::Bind(&HostProcess::OnNatPolicyUpdate, base::Unretained(this)));
+ void StartWatchingPolicy() {
+ policy_watcher_.reset(
+ policy_hack::PolicyWatcher::Create(context_->file_task_runner()));
+ policy_watcher_->StartWatching(
+ base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this)));
}
// Read Host config from disk, returning true if successful.
@@ -314,6 +314,21 @@ class HostProcess
return true;
}
+ void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
+ if (!context_->network_task_runner()->BelongsToCurrentThread()) {
+ context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
+ &HostProcess::OnPolicyUpdate, base::Unretained(this),
+ base::Passed(&policies)));
+ return;
+ }
+
+ bool bool_value;
+ if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
+ &bool_value)) {
+ OnNatPolicyUpdate(bool_value);
+ }
+ }
+
void OnNatPolicyUpdate(bool nat_traversal_enabled) {
if (!context_->network_task_runner()->BelongsToCurrentThread()) {
context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
@@ -498,7 +513,7 @@ class HostProcess
std::string oauth_refresh_token_;
bool oauth_use_official_client_id_;
- scoped_ptr<policy_hack::NatPolicy> nat_policy_;
+ scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
bool allow_nat_traversal_;
scoped_ptr<base::files::FilePathWatcher> config_watcher_;
scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_;
« no previous file with comments | « remoting/host/policy_hack/policy_watcher_win.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698