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

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

Issue 639233002: Remote assistance on Chrome OS Part IV - It2MeHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedbacks Created 6 years, 2 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 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 #ifndef REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ 5 #ifndef REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_
6 #define REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ 6 #define REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "remoting/host/chromoting_host_context.h"
11 12
12 namespace base { 13 namespace base {
13 class SingleThreadTaskRunner; 14 class SingleThreadTaskRunner;
14 class TimeDelta; 15 class TimeDelta;
15 class WaitableEvent; 16 class WaitableEvent;
16 } // namespace base 17 } // namespace base
17 18
18 namespace remoting { 19 namespace remoting {
19 namespace policy_hack { 20 namespace policy_hack {
20 21
(...skipping 10 matching lines...) Expand all
31 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 32 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
32 virtual ~PolicyWatcher(); 33 virtual ~PolicyWatcher();
33 34
34 // This guarantees that the |policy_callback| is called at least once with 35 // This guarantees that the |policy_callback| is called at least once with
35 // the current policies. After that, |policy_callback| will be called 36 // the current policies. After that, |policy_callback| will be called
36 // whenever a change to any policy is detected. It will then be called only 37 // whenever a change to any policy is detected. It will then be called only
37 // with the changed policies. 38 // with the changed policies.
38 virtual void StartWatching(const PolicyCallback& policy_callback); 39 virtual void StartWatching(const PolicyCallback& policy_callback);
39 40
40 // Should be called after StartWatching() before the object is deleted. Calls 41 // Should be called after StartWatching() before the object is deleted. Calls
41 // just wait for |done| to be signaled before deleting the object. 42 // should wait for |stopped_callback| to be called before deleting the object.
42 virtual void StopWatching(base::WaitableEvent* done); 43 virtual void StopWatching(const base::Closure& stopped_callback);
43 44
44 // Implemented by each platform. This message loop should be an IO message 45 // Implemented by each platform. This message loop should be an IO message
45 // loop. 46 // loop.
46 static PolicyWatcher* Create( 47 static PolicyWatcher* Create(
48 ChromotingHostContext* context,
Wez 2014/10/17 17:58:01 Don't pass the ChromotingHostContext around; it's
kelvinp 2014/10/20 00:21:18 I will avoid passing the context but pass the poli
47 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 49 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
48 50
49 // The name of the NAT traversal policy. 51 // The name of the NAT traversal policy.
50 static const char kNatPolicyName[]; 52 static const char kNatPolicyName[];
51 53
52 // The name of the policy for requiring 2-factor authentication. 54 // The name of the policy for requiring 2-factor authentication.
53 static const char kHostRequireTwoFactorPolicyName[]; 55 static const char kHostRequireTwoFactorPolicyName[];
54 56
55 // The name of the host domain policy. 57 // The name of the host domain policy.
56 static const char kHostDomainPolicyName[]; 58 static const char kHostDomainPolicyName[];
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 102
101 // Used for time-based reloads in case something goes wrong with the 103 // Used for time-based reloads in case something goes wrong with the
102 // notification system. 104 // notification system.
103 void ScheduleFallbackReloadTask(); 105 void ScheduleFallbackReloadTask();
104 void ScheduleReloadTask(const base::TimeDelta& delay); 106 void ScheduleReloadTask(const base::TimeDelta& delay);
105 107
106 // Returns a DictionaryValue containing the default values for each policy. 108 // Returns a DictionaryValue containing the default values for each policy.
107 const base::DictionaryValue& Defaults() const; 109 const base::DictionaryValue& Defaults() const;
108 110
109 private: 111 private:
112 virtual void StopWatchingOnPolicyWatcherThread();
110 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 113 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
111 114
112 PolicyCallback policy_callback_; 115 PolicyCallback policy_callback_;
113 116
114 scoped_ptr<base::DictionaryValue> old_policies_; 117 scoped_ptr<base::DictionaryValue> old_policies_;
115 scoped_ptr<base::DictionaryValue> default_values_; 118 scoped_ptr<base::DictionaryValue> default_values_;
116 scoped_ptr<base::DictionaryValue> bad_type_values_; 119 scoped_ptr<base::DictionaryValue> bad_type_values_;
117 120
118 // Allows us to cancel any inflight FileWatcher events or scheduled reloads. 121 // Allows us to cancel any inflight FileWatcher events or scheduled reloads.
119 base::WeakPtrFactory<PolicyWatcher> weak_factory_; 122 base::WeakPtrFactory<PolicyWatcher> weak_factory_;
120 }; 123 };
121 124
122 } // namespace policy_hack 125 } // namespace policy_hack
123 } // namespace remoting 126 } // namespace remoting
124 127
125 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_ 128 #endif // REMOTING_HOST_POLICY_HACK_POLICY_WATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698