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

Side by Side Diff: chrome/browser/policy/cloud/cloud_policy_core.h

Issue 23592017: Fix policy invalidator lifecycle bugs for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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
« no previous file with comments | « chrome/browser/policy/cloud/DEPS ('k') | chrome/browser/policy/cloud/cloud_policy_core.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CORE_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CORE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CORE_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CORE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h"
12 #include "base/prefs/pref_member.h" 13 #include "base/prefs/pref_member.h"
13 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" 14 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
14 15
15 class PrefService; 16 class PrefService;
16 17
17 namespace policy { 18 namespace policy {
18 19
19 class CloudPolicyClient; 20 class CloudPolicyClient;
20 class CloudPolicyRefreshScheduler; 21 class CloudPolicyRefreshScheduler;
21 class CloudPolicyService; 22 class CloudPolicyService;
22 class CloudPolicyStore; 23 class CloudPolicyStore;
23 24
24 // CloudPolicyCore glues together the ingredients that are essential for 25 // CloudPolicyCore glues together the ingredients that are essential for
25 // obtaining a fully-functional cloud policy system: CloudPolicyClient and 26 // obtaining a fully-functional cloud policy system: CloudPolicyClient and
26 // CloudPolicyStore, which are responsible for fetching policy from the cloud 27 // CloudPolicyStore, which are responsible for fetching policy from the cloud
27 // and storing it locally, respectively, as well as a CloudPolicyService 28 // and storing it locally, respectively, as well as a CloudPolicyService
28 // instance that moves data between the two former components, and 29 // instance that moves data between the two former components, and
29 // CloudPolicyRefreshScheduler which triggers periodic refreshes. 30 // CloudPolicyRefreshScheduler which triggers periodic refreshes.
30 class CloudPolicyCore { 31 class CloudPolicyCore {
31 public: 32 public:
33 // Callbacks for policy core events.
34 class Observer {
35 public:
36 virtual ~Observer();
37
38 // Called after the core is connected.
39 virtual void OnCoreConnected(CloudPolicyCore* core) = 0;
40
41 // Called after the refresh scheduler is started.
42 virtual void OnRefreshSchedulerStarted(CloudPolicyCore* core) = 0;
43
44 // Called before the core is disconnected.
45 virtual void OnCoreDisconnecting(CloudPolicyCore* core) = 0;
46 };
47
32 CloudPolicyCore(const PolicyNamespaceKey& policy_ns_key, 48 CloudPolicyCore(const PolicyNamespaceKey& policy_ns_key,
33 CloudPolicyStore* store); 49 CloudPolicyStore* store);
34 ~CloudPolicyCore(); 50 ~CloudPolicyCore();
35 51
36 CloudPolicyClient* client() { return client_.get(); } 52 CloudPolicyClient* client() { return client_.get(); }
37 const CloudPolicyClient* client() const { return client_.get(); } 53 const CloudPolicyClient* client() const { return client_.get(); }
38 54
39 CloudPolicyStore* store() { return store_; } 55 CloudPolicyStore* store() { return store_; }
40 const CloudPolicyStore* store() const { return store_; } 56 const CloudPolicyStore* store() const { return store_; }
41 57
(...skipping 18 matching lines...) Expand all
60 void RefreshSoon(); 76 void RefreshSoon();
61 77
62 // Starts a refresh scheduler in case none is running yet. 78 // Starts a refresh scheduler in case none is running yet.
63 void StartRefreshScheduler(); 79 void StartRefreshScheduler();
64 80
65 // Watches the pref named |refresh_pref_name| in |pref_service| and adjusts 81 // Watches the pref named |refresh_pref_name| in |pref_service| and adjusts
66 // |refresh_scheduler_|'s refresh delay accordingly. 82 // |refresh_scheduler_|'s refresh delay accordingly.
67 void TrackRefreshDelayPref(PrefService* pref_service, 83 void TrackRefreshDelayPref(PrefService* pref_service,
68 const std::string& refresh_pref_name); 84 const std::string& refresh_pref_name);
69 85
86 // Registers an observer to be notified of policy core events.
87 void AddObserver(Observer* observer);
88
89 // Removes the specified observer.
90 void RemoveObserver(Observer* observer);
91
70 private: 92 private:
71 // Updates the refresh scheduler on refresh delay changes. 93 // Updates the refresh scheduler on refresh delay changes.
72 void UpdateRefreshDelayFromPref(); 94 void UpdateRefreshDelayFromPref();
73 95
74 PolicyNamespaceKey policy_ns_key_; 96 PolicyNamespaceKey policy_ns_key_;
75 CloudPolicyStore* store_; 97 CloudPolicyStore* store_;
76 scoped_ptr<CloudPolicyClient> client_; 98 scoped_ptr<CloudPolicyClient> client_;
77 scoped_ptr<CloudPolicyService> service_; 99 scoped_ptr<CloudPolicyService> service_;
78 scoped_ptr<CloudPolicyRefreshScheduler> refresh_scheduler_; 100 scoped_ptr<CloudPolicyRefreshScheduler> refresh_scheduler_;
79 scoped_ptr<IntegerPrefMember> refresh_delay_; 101 scoped_ptr<IntegerPrefMember> refresh_delay_;
102 ObserverList<Observer, true> observers_;
80 103
81 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCore); 104 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCore);
82 }; 105 };
83 106
84 } // namespace policy 107 } // namespace policy
85 108
86 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CORE_H_ 109 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/DEPS ('k') | chrome/browser/policy/cloud/cloud_policy_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698