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

Side by Side Diff: chrome/browser/policy/cloud/cloud_policy_manager.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
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_MANAGER_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
13 #include "base/prefs/pref_member.h" 12 #include "base/prefs/pref_member.h"
14 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" 13 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
15 #include "chrome/browser/policy/cloud/cloud_policy_core.h" 14 #include "chrome/browser/policy/cloud/cloud_policy_core.h"
16 #include "chrome/browser/policy/cloud/cloud_policy_invalidator.h"
17 #include "chrome/browser/policy/cloud/cloud_policy_store.h" 15 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
18 #include "chrome/browser/policy/configuration_policy_provider.h" 16 #include "chrome/browser/policy/configuration_policy_provider.h"
19 17
20 namespace policy { 18 namespace policy {
21 19
22 class PolicyBundle; 20 class PolicyBundle;
23 21
24 // CloudPolicyManager is the main switching central between cloud policy and the 22 // CloudPolicyManager is the main switching central between cloud policy and the
25 // upper layers of the policy stack. It wires up a CloudPolicyCore to the 23 // upper layers of the policy stack. It wires up a CloudPolicyCore to the
26 // ConfigurationPolicyProvider interface. 24 // ConfigurationPolicyProvider interface.
27 // 25 //
28 // This class contains the base functionality, there are subclasses that add 26 // This class contains the base functionality, there are subclasses that add
29 // functionality specific to user-level and device-level cloud policy, such as 27 // functionality specific to user-level and device-level cloud policy, such as
30 // blocking on initial user policy fetch or device enrollment. 28 // blocking on initial user policy fetch or device enrollment.
31 class CloudPolicyManager : public ConfigurationPolicyProvider, 29 class CloudPolicyManager : public ConfigurationPolicyProvider,
32 public CloudPolicyStore::Observer, 30 public CloudPolicyStore::Observer {
33 public CloudPolicyInvalidationHandler {
34 public: 31 public:
35 CloudPolicyManager(const PolicyNamespaceKey& policy_ns_key, 32 CloudPolicyManager(const PolicyNamespaceKey& policy_ns_key,
36 CloudPolicyStore* cloud_policy_store); 33 CloudPolicyStore* cloud_policy_store);
37 virtual ~CloudPolicyManager(); 34 virtual ~CloudPolicyManager();
38 35
39 CloudPolicyCore* core() { return &core_; } 36 CloudPolicyCore* core() { return &core_; }
40 const CloudPolicyCore* core() const { return &core_; } 37 const CloudPolicyCore* core() const { return &core_; }
41 38
42 // Enables invalidations to the cloud policy. This method must only be
43 // called once.
44 // |initialize_invalidator| should initialize the invalidator when invoked.
45 // If the manager is ready to receive invalidations, it will be invoked
46 // immediately; otherwise, it will be invoked upon becoming ready.
47 void EnableInvalidations(const base::Closure& initialize_invalidator);
48
49 // ConfigurationPolicyProvider: 39 // ConfigurationPolicyProvider:
50 virtual void Shutdown() OVERRIDE; 40 virtual void Shutdown() OVERRIDE;
51 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; 41 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
52 virtual void RefreshPolicies() OVERRIDE; 42 virtual void RefreshPolicies() OVERRIDE;
53 43
54 // CloudPolicyStore::Observer: 44 // CloudPolicyStore::Observer:
55 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE; 45 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE;
56 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE; 46 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE;
57 47
58 // CloudPolicyInvalidationHandler:
59 virtual void SetInvalidationInfo(
60 int64 version,
61 const std::string& payload) OVERRIDE;
62 virtual void InvalidatePolicy() OVERRIDE;
63 virtual void OnInvalidatorStateChanged(bool invalidations_enabled) OVERRIDE;
64
65 protected: 48 protected:
66 // Check whether fully initialized and if so, publish policy by calling 49 // Check whether fully initialized and if so, publish policy by calling
67 // ConfigurationPolicyStore::UpdatePolicy(). 50 // ConfigurationPolicyStore::UpdatePolicy().
68 void CheckAndPublishPolicy(); 51 void CheckAndPublishPolicy();
69 52
70 // Starts the policy refresh scheduler. This must be called instead of calling
71 // enabling the scheduler on core() directly so that invalidations are
72 // enabled correctly.
73 void StartRefreshScheduler();
74
75 // Called by CheckAndPublishPolicy() to create a bundle with the current 53 // Called by CheckAndPublishPolicy() to create a bundle with the current
76 // policies. 54 // policies.
77 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle(); 55 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle();
78 56
79 // Convenience accessors to core() components. 57 // Convenience accessors to core() components.
80 CloudPolicyClient* client() { return core_.client(); } 58 CloudPolicyClient* client() { return core_.client(); }
81 const CloudPolicyClient* client() const { return core_.client(); } 59 const CloudPolicyClient* client() const { return core_.client(); }
82 CloudPolicyStore* store() { return core_.store(); } 60 CloudPolicyStore* store() { return core_.store(); }
83 const CloudPolicyStore* store() const { return core_.store(); } 61 const CloudPolicyStore* store() const { return core_.store(); }
84 CloudPolicyService* service() { return core_.service(); } 62 CloudPolicyService* service() { return core_.service(); }
85 const CloudPolicyService* service() const { return core_.service(); } 63 const CloudPolicyService* service() const { return core_.service(); }
86 64
87 private: 65 private:
88 // Completion handler for policy refresh operations. 66 // Completion handler for policy refresh operations.
89 void OnRefreshComplete(bool success); 67 void OnRefreshComplete(bool success);
90 68
91 CloudPolicyCore core_; 69 CloudPolicyCore core_;
92 70
93 // Whether there's a policy refresh operation pending, in which case all 71 // Whether there's a policy refresh operation pending, in which case all
94 // policy update notifications are deferred until after it completes. 72 // policy update notifications are deferred until after it completes.
95 bool waiting_for_policy_refresh_; 73 bool waiting_for_policy_refresh_;
96 74
97 // Used to initialize the policy invalidator once the refresh scheduler
98 // starts.
99 base::Closure initialize_invalidator_;
100
101 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager); 75 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager);
102 }; 76 };
103 77
104 } // namespace policy 78 } // namespace policy
105 79
106 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ 80 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/cloud_policy_invalidator_unittest.cc ('k') | chrome/browser/policy/cloud/cloud_policy_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698