| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Most of this code is copied from: | 5 // Most of this code is copied from: |
| 6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} | 6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} |
| 7 | 7 |
| 8 #include "remoting/host/policy_hack/nat_policy.h" | 8 #include "remoting/host/policy_hack/nat_policy.h" |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 DCHECK(OnPolicyThread()); | 70 DCHECK(OnPolicyThread()); |
| 71 ScheduleReloadTask( | 71 ScheduleReloadTask( |
| 72 base::TimeDelta::FromMinutes(kFallbackReloadDelayMinutes)); | 72 base::TimeDelta::FromMinutes(kFallbackReloadDelayMinutes)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void NatPolicy::ScheduleReloadTask(const base::TimeDelta& delay) { | 75 void NatPolicy::ScheduleReloadTask(const base::TimeDelta& delay) { |
| 76 DCHECK(OnPolicyThread()); | 76 DCHECK(OnPolicyThread()); |
| 77 message_loop_proxy_->PostDelayedTask( | 77 message_loop_proxy_->PostDelayedTask( |
| 78 FROM_HERE, | 78 FROM_HERE, |
| 79 base::Bind(&NatPolicy::Reload, weak_factory_.GetWeakPtr()), | 79 base::Bind(&NatPolicy::Reload, weak_factory_.GetWeakPtr()), |
| 80 delay.InMilliseconds()); | 80 delay); |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool NatPolicy::OnPolicyThread() const { | 83 bool NatPolicy::OnPolicyThread() const { |
| 84 return message_loop_proxy_->BelongsToCurrentThread(); | 84 return message_loop_proxy_->BelongsToCurrentThread(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void NatPolicy::UpdateNatPolicy(base::DictionaryValue* new_policy) { | 87 void NatPolicy::UpdateNatPolicy(base::DictionaryValue* new_policy) { |
| 88 DCHECK(OnPolicyThread()); | 88 DCHECK(OnPolicyThread()); |
| 89 bool new_nat_enabled_state = false; | 89 bool new_nat_enabled_state = false; |
| 90 if (!new_policy->HasKey(kNatPolicyName)) { | 90 if (!new_policy->HasKey(kNatPolicyName)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 if (!first_state_published_ || | 103 if (!first_state_published_ || |
| 104 (new_nat_enabled_state != current_nat_enabled_state_)) { | 104 (new_nat_enabled_state != current_nat_enabled_state_)) { |
| 105 first_state_published_ = true; | 105 first_state_published_ = true; |
| 106 current_nat_enabled_state_ = new_nat_enabled_state; | 106 current_nat_enabled_state_ = new_nat_enabled_state; |
| 107 nat_enabled_cb_.Run(current_nat_enabled_state_); | 107 nat_enabled_cb_.Run(current_nat_enabled_state_); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace policy_hack | 111 } // namespace policy_hack |
| 112 } // namespace remoting | 112 } // namespace remoting |
| OLD | NEW |