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

Side by Side Diff: components/policy/core/common/cloud/cloud_policy_client.h

Issue 756133002: Purge cache when the server removes the policy for an extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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
« no previous file with comments | « no previous file | components/policy/core/common/cloud/cloud_policy_client.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 COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 20 matching lines...) Expand all
31 // Implements the core logic required to talk to the device management service. 31 // Implements the core logic required to talk to the device management service.
32 // Also keeps track of the current state of the association with the service, 32 // Also keeps track of the current state of the association with the service,
33 // such as whether there is a valid registration (DMToken is present in that 33 // such as whether there is a valid registration (DMToken is present in that
34 // case) and whether and what errors occurred in the latest request. 34 // case) and whether and what errors occurred in the latest request.
35 // 35 //
36 // Note that CloudPolicyClient doesn't do any validation of policy responses 36 // Note that CloudPolicyClient doesn't do any validation of policy responses
37 // such as signature and time stamp checks. These happen once the policy gets 37 // such as signature and time stamp checks. These happen once the policy gets
38 // installed in the cloud policy cache. 38 // installed in the cloud policy cache.
39 class POLICY_EXPORT CloudPolicyClient { 39 class POLICY_EXPORT CloudPolicyClient {
40 public: 40 public:
41 // A set of PolicyNamespaceKeys to fetch.
42 typedef std::set<PolicyNamespaceKey> NamespaceSet;
43
41 // Maps a PolicyNamespaceKey to its corresponding PolicyFetchResponse. 44 // Maps a PolicyNamespaceKey to its corresponding PolicyFetchResponse.
42 typedef std::map<PolicyNamespaceKey, 45 typedef std::map<PolicyNamespaceKey,
43 enterprise_management::PolicyFetchResponse*> ResponseMap; 46 enterprise_management::PolicyFetchResponse*> ResponseMap;
44 47
45 // A callback which receives boolean status of an operation. If the operation 48 // A callback which receives boolean status of an operation. If the operation
46 // succeeded, |status| is true. 49 // succeeded, |status| is true.
47 typedef base::Callback<void(bool status)> StatusCallback; 50 typedef base::Callback<void(bool status)> StatusCallback;
48 51
49 // Observer interface for state and policy changes. 52 // Observer interface for state and policy changes.
50 class POLICY_EXPORT Observer { 53 class POLICY_EXPORT Observer {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 DeviceMode device_mode() const { return device_mode_; } 192 DeviceMode device_mode() const { return device_mode_; }
190 193
191 // The policy responses as obtained by the last request to the cloud. These 194 // The policy responses as obtained by the last request to the cloud. These
192 // policies haven't gone through verification, so their contents cannot be 195 // policies haven't gone through verification, so their contents cannot be
193 // trusted. Use CloudPolicyStore::policy() and CloudPolicyStore::policy_map() 196 // trusted. Use CloudPolicyStore::policy() and CloudPolicyStore::policy_map()
194 // instead for making policy decisions. 197 // instead for making policy decisions.
195 const ResponseMap& responses() const { 198 const ResponseMap& responses() const {
196 return responses_; 199 return responses_;
197 } 200 }
198 201
202 // Returns a set with the policy namespaces that were included in the fetch
203 // request that produced the current |responses()|. This can be used to
204 // determine if a namespace is missing because it wasn't requested or because
205 // the server didn't include a response.
Mattias Nissler (ping if slow) 2014/11/26 13:44:14 Hm, this moves the responsibility to do the diffin
206 const NamespaceSet& namespaces_requested() const {
207 return namespaces_requested_;
208 }
209
199 // Returns the policy response for |policy_ns_key|, if found in |responses()|; 210 // Returns the policy response for |policy_ns_key|, if found in |responses()|;
200 // otherwise returns NULL. 211 // otherwise returns NULL.
201 const enterprise_management::PolicyFetchResponse* GetPolicyFor( 212 const enterprise_management::PolicyFetchResponse* GetPolicyFor(
202 const PolicyNamespaceKey& policy_ns_key) const; 213 const PolicyNamespaceKey& policy_ns_key) const;
203 214
204 DeviceManagementStatus status() const { 215 DeviceManagementStatus status() const {
205 return status_; 216 return status_;
206 } 217 }
207 218
208 const std::string& robot_api_auth_code() const { 219 const std::string& robot_api_auth_code() const {
209 return robot_api_auth_code_; 220 return robot_api_auth_code_;
210 } 221 }
211 222
212 // Returns the invalidation version that was used for the last FetchPolicy. 223 // Returns the invalidation version that was used for the last FetchPolicy.
213 // Observers can call this method from their OnPolicyFetched method to 224 // Observers can call this method from their OnPolicyFetched method to
214 // determine which at which invalidation version the policy was fetched. 225 // determine which at which invalidation version the policy was fetched.
215 int64 fetched_invalidation_version() const { 226 int64 fetched_invalidation_version() const {
216 return fetched_invalidation_version_; 227 return fetched_invalidation_version_;
217 } 228 }
218 229
219 scoped_refptr<net::URLRequestContextGetter> GetRequestContext(); 230 scoped_refptr<net::URLRequestContextGetter> GetRequestContext();
220 231
221 protected: 232 protected:
222 // A set of PolicyNamespaceKeys to fetch.
223 typedef std::set<PolicyNamespaceKey> NamespaceSet;
224
225 // Callback for retries of registration requests. 233 // Callback for retries of registration requests.
226 void OnRetryRegister(DeviceManagementRequestJob* job); 234 void OnRetryRegister(DeviceManagementRequestJob* job);
227 235
228 // Callback for registration requests. 236 // Callback for registration requests.
229 void OnRegisterCompleted( 237 void OnRegisterCompleted(
230 DeviceManagementStatus status, 238 DeviceManagementStatus status,
231 int net_error, 239 int net_error,
232 const enterprise_management::DeviceManagementResponse& response); 240 const enterprise_management::DeviceManagementResponse& response);
233 241
234 // Callback for policy fetch requests. 242 // Callback for policy fetch requests.
235 void OnPolicyFetchCompleted( 243 void OnPolicyFetchCompleted(
244 const NamespaceSet& namespaces_requested,
236 DeviceManagementStatus status, 245 DeviceManagementStatus status,
237 int net_error, 246 int net_error,
238 const enterprise_management::DeviceManagementResponse& response); 247 const enterprise_management::DeviceManagementResponse& response);
239 248
240 // Callback for robot account api authorization requests. 249 // Callback for robot account api authorization requests.
241 void OnFetchRobotAuthCodesCompleted( 250 void OnFetchRobotAuthCodesCompleted(
242 DeviceManagementStatus status, 251 DeviceManagementStatus status,
243 int net_error, 252 int net_error,
244 const enterprise_management::DeviceManagementResponse& response); 253 const enterprise_management::DeviceManagementResponse& response);
245 254
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 DeviceManagementService* service_; 299 DeviceManagementService* service_;
291 scoped_ptr<DeviceManagementRequestJob> request_job_; 300 scoped_ptr<DeviceManagementRequestJob> request_job_;
292 301
293 // Status upload data is produced by |status_provider_|. 302 // Status upload data is produced by |status_provider_|.
294 StatusProvider* status_provider_; 303 StatusProvider* status_provider_;
295 304
296 // The policy responses returned by the last policy fetch operation. 305 // The policy responses returned by the last policy fetch operation.
297 ResponseMap responses_; 306 ResponseMap responses_;
298 DeviceManagementStatus status_; 307 DeviceManagementStatus status_;
299 308
309 // The namespaces that were requested in the last successful policy fetch.
310 NamespaceSet namespaces_requested_;
311
300 ObserverList<Observer, true> observers_; 312 ObserverList<Observer, true> observers_;
301 scoped_refptr<net::URLRequestContextGetter> request_context_; 313 scoped_refptr<net::URLRequestContextGetter> request_context_;
302 314
303 private: 315 private:
304 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); 316 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient);
305 }; 317 };
306 318
307 } // namespace policy 319 } // namespace policy
308 320
309 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ 321 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | components/policy/core/common/cloud/cloud_policy_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698