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

Side by Side Diff: remoting/host/policy_hack/policy_watcher.cc

Issue 639233002: Remote assistance on Chrome OS Part IV - It2MeHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build error on ozone Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
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/policy_watcher.h" 8 #include "remoting/host/policy_hack/policy_watcher.h"
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/synchronization/waitable_event.h"
16 #include "base/time/time.h" 15 #include "base/time/time.h"
17 #include "base/values.h" 16 #include "base/values.h"
18 #include "remoting/host/dns_blackhole_checker.h" 17 #include "remoting/host/dns_blackhole_checker.h"
19 18
20 #if !defined(NDEBUG) 19 #if !defined(NDEBUG)
21 #include "base/json/json_reader.h" 20 #include "base/json/json_reader.h"
22 #endif 21 #endif
23 22
24 namespace remoting { 23 namespace remoting {
25 namespace policy_hack { 24 namespace policy_hack {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 base::Bind(&PolicyWatcher::StartWatching, 157 base::Bind(&PolicyWatcher::StartWatching,
159 base::Unretained(this), 158 base::Unretained(this),
160 policy_callback)); 159 policy_callback));
161 return; 160 return;
162 } 161 }
163 162
164 policy_callback_ = policy_callback; 163 policy_callback_ = policy_callback;
165 StartWatchingInternal(); 164 StartWatchingInternal();
166 } 165 }
167 166
168 void PolicyWatcher::StopWatching(base::WaitableEvent* done) { 167 void PolicyWatcher::StopWatching(const base::Closure& stopped_callback) {
169 if (!OnPolicyWatcherThread()) { 168 task_runner_->PostTaskAndReply(
170 task_runner_->PostTask(FROM_HERE, 169 FROM_HERE, base::Bind(&PolicyWatcher::StopWatchingOnPolicyWatcherThread,
171 base::Bind(&PolicyWatcher::StopWatching, 170 base::Unretained(this)),
172 base::Unretained(this), done)); 171 stopped_callback);
173 return; 172 }
174 }
175 173
174 void PolicyWatcher::StopWatchingOnPolicyWatcherThread() {
176 StopWatchingInternal(); 175 StopWatchingInternal();
177 weak_factory_.InvalidateWeakPtrs(); 176 weak_factory_.InvalidateWeakPtrs();
178 policy_callback_.Reset(); 177 policy_callback_.Reset();
179
180 done->Signal();
181 } 178 }
182 179
183 void PolicyWatcher::ScheduleFallbackReloadTask() { 180 void PolicyWatcher::ScheduleFallbackReloadTask() {
184 DCHECK(OnPolicyWatcherThread()); 181 DCHECK(OnPolicyWatcherThread());
185 ScheduleReloadTask( 182 ScheduleReloadTask(
186 base::TimeDelta::FromMinutes(kFallbackReloadDelayMinutes)); 183 base::TimeDelta::FromMinutes(kFallbackReloadDelayMinutes));
187 } 184 }
188 185
189 void PolicyWatcher::ScheduleReloadTask(const base::TimeDelta& delay) { 186 void PolicyWatcher::ScheduleReloadTask(const base::TimeDelta& delay) {
190 DCHECK(OnPolicyWatcherThread()); 187 DCHECK(OnPolicyWatcherThread());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 old_policies_.swap(new_policies); 225 old_policies_.swap(new_policies);
229 226
230 // Notify our client of the changed policies. 227 // Notify our client of the changed policies.
231 if (!changed_policies->empty()) { 228 if (!changed_policies->empty()) {
232 policy_callback_.Run(changed_policies.Pass()); 229 policy_callback_.Run(changed_policies.Pass());
233 } 230 }
234 } 231 }
235 232
236 } // namespace policy_hack 233 } // namespace policy_hack
237 } // namespace remoting 234 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/policy_hack/policy_watcher.h ('k') | remoting/host/policy_hack/policy_watcher_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698