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

Side by Side Diff: chrome/browser/policy/cloud_policy_store.h

Issue 11415094: Split UserCloudPolicyManager implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DeviceCloudPolicyManagerChromeOSTest.EnrolledDevice failure. Created 8 years 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 | Annotate | Revision Log
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_POLICY_STORE_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "chrome/browser/policy/cloud_policy_validator.h" 11 #include "chrome/browser/policy/cloud_policy_validator.h"
12 #include "chrome/browser/policy/policy_map.h" 12 #include "chrome/browser/policy/policy_map.h"
13 #include "chrome/browser/policy/proto/device_management_backend.pb.h" 13 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
14 14
15 class Profile;
16
17 namespace policy { 15 namespace policy {
18 16
19 // Defines the low-level interface used by the cloud policy code to: 17 // Defines the low-level interface used by the cloud policy code to:
20 // 1. Validate policy blobs that should be applied locally 18 // 1. Validate policy blobs that should be applied locally
21 // 2. Persist policy blobs 19 // 2. Persist policy blobs
22 // 3. Decode policy blobs to PolicyMap representation 20 // 3. Decode policy blobs to PolicyMap representation
23 class CloudPolicyStore { 21 class CloudPolicyStore {
24 public: 22 public:
25 // Status codes. 23 // Status codes.
26 enum Status { 24 enum Status {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Errors generate OnStoreError() notifications. 80 // Errors generate OnStoreError() notifications.
83 virtual void Store( 81 virtual void Store(
84 const enterprise_management::PolicyFetchResponse& policy) = 0; 82 const enterprise_management::PolicyFetchResponse& policy) = 0;
85 83
86 // Load the current policy blob from persistent storage. Pending load/store 84 // Load the current policy blob from persistent storage. Pending load/store
87 // operations will be canceled. This may trigger asynchronous operations. 85 // operations will be canceled. This may trigger asynchronous operations.
88 // Upon success, OnStoreLoaded() will be called on the registered observers. 86 // Upon success, OnStoreLoaded() will be called on the registered observers.
89 // Otherwise, OnStoreError() reports the reason for failure. 87 // Otherwise, OnStoreError() reports the reason for failure.
90 virtual void Load() = 0; 88 virtual void Load() = 0;
91 89
92 // Deletes any existing policy blob and notifies observers via OnStoreLoaded()
93 // that the blob has changed. Virtual for mocks.
94 virtual void Clear();
95
96 // Registers an observer to be notified when policy changes. 90 // Registers an observer to be notified when policy changes.
97 void AddObserver(Observer* observer); 91 void AddObserver(Observer* observer);
98 92
99 // Removes the specified observer. 93 // Removes the specified observer.
100 void RemoveObserver(Observer* observer); 94 void RemoveObserver(Observer* observer);
101 95
102 // Factory method to create a CloudPolicyStore appropriate for the current
103 // platform, for storing user policy for the user associated with the passed
104 // |profile|. Implementation is defined in the individual platform store
105 // files.
106 static scoped_ptr<CloudPolicyStore> CreateUserPolicyStore(
107 Profile* profile,
108 bool force_immediate_policy_load);
109
110 protected: 96 protected:
111 // Invokes the corresponding callback on all registered observers. 97 // Invokes the corresponding callback on all registered observers.
112 void NotifyStoreLoaded(); 98 void NotifyStoreLoaded();
113 void NotifyStoreError(); 99 void NotifyStoreError();
114 100
115 // Invoked by Clear() to remove stored policy.
116 virtual void RemoveStoredPolicy() = 0;
117
118 // Decoded version of the currently effective policy. 101 // Decoded version of the currently effective policy.
119 PolicyMap policy_map_; 102 PolicyMap policy_map_;
120 103
121 // Currently effective policy. 104 // Currently effective policy.
122 scoped_ptr<enterprise_management::PolicyData> policy_; 105 scoped_ptr<enterprise_management::PolicyData> policy_;
123 106
124 // Latest status code. 107 // Latest status code.
125 Status status_; 108 Status status_;
126 109
127 // Latest validation status. 110 // Latest validation status.
128 CloudPolicyValidatorBase::Status validation_status_; 111 CloudPolicyValidatorBase::Status validation_status_;
129 112
130 private: 113 private:
131 // Whether the store has completed asynchronous initialization, which is 114 // Whether the store has completed asynchronous initialization, which is
132 // triggered by calling Load(). 115 // triggered by calling Load().
133 bool is_initialized_; 116 bool is_initialized_;
134 117
135 ObserverList<Observer, true> observers_; 118 ObserverList<Observer, true> observers_;
136 119
137 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStore); 120 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStore);
138 }; 121 };
139 122
140 } // namespace policy 123 } // namespace policy
141 124
142 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ 125 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_manager_unittest.cc ('k') | chrome/browser/policy/cloud_policy_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698