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

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: Pass the policy dictionary as a scoped_ptr. 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
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..befa39ac122796ad917b0c66536600af2012ac70 100644
--- a/remoting/host/remoting_me2me_host.cc
+++ b/remoting/host/remoting_me2me_host.cc
@@ -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_;

Powered by Google App Engine
This is Rietveld 408576698