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

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

Issue 19733003: Implement cloud policy invalidations using the invalidation service framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.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 #include "chrome/browser/policy/cloud/cloud_policy_core.h" 15 #include "chrome/browser/policy/cloud/cloud_policy_core.h"
16 #include "chrome/browser/policy/cloud/cloud_policy_invalidator.h"
15 #include "chrome/browser/policy/cloud/cloud_policy_store.h" 17 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
16 #include "chrome/browser/policy/configuration_policy_provider.h" 18 #include "chrome/browser/policy/configuration_policy_provider.h"
17 19
18 namespace policy { 20 namespace policy {
19 21
20 class PolicyBundle; 22 class PolicyBundle;
21 23
22 // CloudPolicyManager is the main switching central between cloud policy and the 24 // CloudPolicyManager is the main switching central between cloud policy and the
23 // upper layers of the policy stack. It wires up a CloudPolicyCore to the 25 // upper layers of the policy stack. It wires up a CloudPolicyCore to the
24 // ConfigurationPolicyProvider interface. 26 // ConfigurationPolicyProvider interface.
25 // 27 //
26 // This class contains the base functionality, there are subclasses that add 28 // This class contains the base functionality, there are subclasses that add
27 // functionality specific to user-level and device-level cloud policy, such as 29 // functionality specific to user-level and device-level cloud policy, such as
28 // blocking on initial user policy fetch or device enrollment. 30 // blocking on initial user policy fetch or device enrollment.
29 class CloudPolicyManager : public ConfigurationPolicyProvider, 31 class CloudPolicyManager : public ConfigurationPolicyProvider,
30 public CloudPolicyStore::Observer { 32 public CloudPolicyStore::Observer,
33 public CloudPolicyInvalidationHandler {
31 public: 34 public:
32 CloudPolicyManager(const PolicyNamespaceKey& policy_ns_key, 35 CloudPolicyManager(const PolicyNamespaceKey& policy_ns_key,
33 CloudPolicyStore* cloud_policy_store); 36 CloudPolicyStore* cloud_policy_store);
34 virtual ~CloudPolicyManager(); 37 virtual ~CloudPolicyManager();
35 38
36 CloudPolicyCore* core() { return &core_; } 39 CloudPolicyCore* core() { return &core_; }
37 const CloudPolicyCore* core() const { return &core_; } 40 const CloudPolicyCore* core() const { return &core_; }
38 41
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);
Mattias Nissler (ping if slow) 2013/08/28 14:20:40 This really shouldn't be here. The invalidator sho
48
39 // ConfigurationPolicyProvider: 49 // ConfigurationPolicyProvider:
40 virtual void Shutdown() OVERRIDE; 50 virtual void Shutdown() OVERRIDE;
41 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; 51 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
42 virtual void RefreshPolicies() OVERRIDE; 52 virtual void RefreshPolicies() OVERRIDE;
43 53
44 // CloudPolicyStore::Observer: 54 // CloudPolicyStore::Observer:
45 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE; 55 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE;
46 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE; 56 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE;
47 57
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
48 protected: 65 protected:
49 // Check whether fully initialized and if so, publish policy by calling 66 // Check whether fully initialized and if so, publish policy by calling
50 // ConfigurationPolicyStore::UpdatePolicy(). 67 // ConfigurationPolicyStore::UpdatePolicy().
51 void CheckAndPublishPolicy(); 68 void CheckAndPublishPolicy();
52 69
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
53 // Called by CheckAndPublishPolicy() to create a bundle with the current 75 // Called by CheckAndPublishPolicy() to create a bundle with the current
54 // policies. 76 // policies.
55 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle(); 77 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle();
56 78
57 // Convenience accessors to core() components. 79 // Convenience accessors to core() components.
58 CloudPolicyClient* client() { return core_.client(); } 80 CloudPolicyClient* client() { return core_.client(); }
59 const CloudPolicyClient* client() const { return core_.client(); } 81 const CloudPolicyClient* client() const { return core_.client(); }
60 CloudPolicyStore* store() { return core_.store(); } 82 CloudPolicyStore* store() { return core_.store(); }
61 const CloudPolicyStore* store() const { return core_.store(); } 83 const CloudPolicyStore* store() const { return core_.store(); }
62 CloudPolicyService* service() { return core_.service(); } 84 CloudPolicyService* service() { return core_.service(); }
63 const CloudPolicyService* service() const { return core_.service(); } 85 const CloudPolicyService* service() const { return core_.service(); }
64 86
65 private: 87 private:
66 // Completion handler for policy refresh operations. 88 // Completion handler for policy refresh operations.
67 void OnRefreshComplete(bool success); 89 void OnRefreshComplete(bool success);
68 90
69 CloudPolicyCore core_; 91 CloudPolicyCore core_;
70 92
71 // Whether there's a policy refresh operation pending, in which case all 93 // Whether there's a policy refresh operation pending, in which case all
72 // policy update notifications are deferred until after it completes. 94 // policy update notifications are deferred until after it completes.
73 bool waiting_for_policy_refresh_; 95 bool waiting_for_policy_refresh_;
74 96
97 // Used to initialize the policy invalidator once the refresh scheduler
98 // starts.
99 base::Closure initialize_invalidator_;
100
75 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager); 101 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager);
76 }; 102 };
77 103
78 } // namespace policy 104 } // namespace policy
79 105
80 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ 106 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698