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

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, 5 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/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/prefs/pref_member.h" 12 #include "base/prefs/pref_member.h"
13 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" 13 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
14 #include "chrome/browser/policy/cloud/cloud_policy_core.h" 14 #include "chrome/browser/policy/cloud/cloud_policy_core.h"
15 #include "chrome/browser/policy/cloud/cloud_policy_invalidator.h"
15 #include "chrome/browser/policy/cloud/cloud_policy_store.h" 16 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
16 #include "chrome/browser/policy/configuration_policy_provider.h" 17 #include "chrome/browser/policy/configuration_policy_provider.h"
17 18
18 namespace policy { 19 namespace policy {
19 20
20 class PolicyBundle; 21 class PolicyBundle;
21 22
22 // CloudPolicyManager is the main switching central between cloud policy and the 23 // 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 24 // upper layers of the policy stack. It wires up a CloudPolicyCore to the
24 // ConfigurationPolicyProvider interface. 25 // ConfigurationPolicyProvider interface.
25 // 26 //
26 // This class contains the base functionality, there are subclasses that add 27 // This class contains the base functionality, there are subclasses that add
27 // functionality specific to user-level and device-level cloud policy, such as 28 // functionality specific to user-level and device-level cloud policy, such as
28 // blocking on initial user policy fetch or device enrollment. 29 // blocking on initial user policy fetch or device enrollment.
29 class CloudPolicyManager : public ConfigurationPolicyProvider, 30 class CloudPolicyManager : public ConfigurationPolicyProvider,
30 public CloudPolicyStore::Observer { 31 public CloudPolicyStore::Observer,
32 public CloudPolicyInvalidationHandler {
31 public: 33 public:
32 CloudPolicyManager(const PolicyNamespaceKey& policy_ns_key, 34 CloudPolicyManager(const PolicyNamespaceKey& policy_ns_key,
33 CloudPolicyStore* cloud_policy_store); 35 CloudPolicyStore* cloud_policy_store);
34 virtual ~CloudPolicyManager(); 36 virtual ~CloudPolicyManager();
35 37
36 CloudPolicyCore* core() { return &core_; } 38 CloudPolicyCore* core() { return &core_; }
37 const CloudPolicyCore* core() const { return &core_; } 39 const CloudPolicyCore* core() const { return &core_; }
38 40
39 // ConfigurationPolicyProvider: 41 // ConfigurationPolicyProvider:
40 virtual void Shutdown() OVERRIDE; 42 virtual void Shutdown() OVERRIDE;
41 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; 43 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
42 virtual void RefreshPolicies() OVERRIDE; 44 virtual void RefreshPolicies() OVERRIDE;
43 45
44 // CloudPolicyStore::Observer: 46 // CloudPolicyStore::Observer:
45 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE; 47 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE;
46 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE; 48 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE;
47 49
50 // CloudPolicyInvalidationHandler:
51 virtual void SetInvalidationInfo(
52 int64 version,
53 const std::string& payload) OVERRIDE;
54 virtual void InvalidatePolicy() OVERRIDE;
55 virtual void OnInvalidatorStateChanged(bool invalidations_enabled) OVERRIDE;
56
48 protected: 57 protected:
49 // Check whether fully initialized and if so, publish policy by calling 58 // Check whether fully initialized and if so, publish policy by calling
50 // ConfigurationPolicyStore::UpdatePolicy(). 59 // ConfigurationPolicyStore::UpdatePolicy().
51 void CheckAndPublishPolicy(); 60 void CheckAndPublishPolicy();
52 61
62 // Starts the policy refresh scheduler. This must be called instead of calling
63 // enabling the scheduler on core() directly so that invalidations received
64 // before the refresh scheduler is started are handled correctly.
65 void StartRefreshScheduler();
66
53 // Called by CheckAndPublishPolicy() to create a bundle with the current 67 // Called by CheckAndPublishPolicy() to create a bundle with the current
54 // policies. 68 // policies.
55 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle(); 69 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle();
56 70
57 // Convenience accessors to core() components. 71 // Convenience accessors to core() components.
58 CloudPolicyClient* client() { return core_.client(); } 72 CloudPolicyClient* client() { return core_.client(); }
59 const CloudPolicyClient* client() const { return core_.client(); } 73 const CloudPolicyClient* client() const { return core_.client(); }
60 CloudPolicyStore* store() { return core_.store(); } 74 CloudPolicyStore* store() { return core_.store(); }
61 const CloudPolicyStore* store() const { return core_.store(); } 75 const CloudPolicyStore* store() const { return core_.store(); }
62 CloudPolicyService* service() { return core_.service(); } 76 CloudPolicyService* service() { return core_.service(); }
63 const CloudPolicyService* service() const { return core_.service(); } 77 const CloudPolicyService* service() const { return core_.service(); }
64 78
65 private: 79 private:
66 // Completion handler for policy refresh operations. 80 // Completion handler for policy refresh operations.
67 void OnRefreshComplete(bool success); 81 void OnRefreshComplete(bool success);
68 82
69 CloudPolicyCore core_; 83 CloudPolicyCore core_;
70 84
71 // Whether there's a policy refresh operation pending, in which case all 85 // Whether there's a policy refresh operation pending, in which case all
72 // policy update notifications are deferred until after it completes. 86 // policy update notifications are deferred until after it completes.
73 bool waiting_for_policy_refresh_; 87 bool waiting_for_policy_refresh_;
74 88
89 // Replays the latest invalidation that occurred before the refresh
90 // scheduler was started. Without storing the information, invalidations
91 // generated before the refresh scheduler started would be lost.
92 CloudPolicyInvalidationReplayer invalidation_replayer_;
rlarocque 2013/07/25 19:23:40 Are you sure this is necessary? The InvalidationS
Steve Condie 2013/07/26 01:39:25 With the new way of managing the lifetime of the U
Steve Condie 2013/07/26 08:47:27 After thinking about it more, there is a fairly st
93
75 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager); 94 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager);
76 }; 95 };
77 96
78 } // namespace policy 97 } // namespace policy
79 98
80 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ 99 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698