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

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

Issue 10092010: Add CloudPolicyService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/observer_list.h"
11 #include "chrome/browser/policy/policy_map.h"
12 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
13
14 namespace policy {
15
16 // Defines the low-level interface used by the cloud policy code to:
17 // 1. Validate policy blobs that should be applied locally
18 // 2. Persist policy blobs
19 // 3. Decode policy blobs to PolicyMap representation
20 class CloudPolicyStore {
21 public:
22 // Status codes.
23 enum Status {
24 // Everything is in good order.
25 STATUS_SUCCESS,
26 };
27
28 // Callbacks for policy store events. Most importantly, policy updates.
29 class Observer {
30 public:
31 virtual ~Observer();
32
33 // Called on changes to store->policy().
34 virtual void OnPolicyLoaded(CloudPolicyStore* store) = 0;
Joao da Silva 2012/04/17 00:30:58 The comments refer to this as OnPolicyUpdated(). S
Mattias Nissler (ping if slow) 2012/05/22 14:14:26 Done.
35
36 // Called upon encountering errors.
37 virtual void OnStoreError(CloudPolicyStore* store) = 0;
38 };
39
40 CloudPolicyStore();
41 virtual ~CloudPolicyStore();
42
43 const PolicyMap& policy_map() const { return policy_map_; }
44 const enterprise_management::PolicyData& policy() const { return policy_; }
45 const Status status() const { return status_; }
46
47 // Store a new policy blob. Pending store operations will be canceled. The
48 // store operation may proceed asynchronously and observers are notified once
49 // the operation finishes. If successful, OnPolicyUpdated() will be invoked on
50 // the observers and the updated policy can be read through policy(). Errors
51 // generate OnStoreError() notifications.
52 virtual void Store(
53 const enterprise_management::PolicyFetchResponse& policy) = 0;
54
55 // Load the current policy blob from persistent storage. This may trigger
56 // asynchronous operations. Upon success, OnPolicyUpdated() will be called on
57 // the registered observers. Otherwise, OnStoreError() reports the reason for
58 // failure.
59 virtual void Load() = 0;
60
61 // Registers an observer to be notified when policy changes.
62 void AddObserver(Observer* observer);
63
64 // Removes the specified observer.
65 void RemoveObserver(Observer* observer);
66
67 protected:
68 // Decoded version of the currently effective policy.
69 PolicyMap policy_map_;
70
71 // Currently effective policy.
72 enterprise_management::PolicyData policy_;
73
74 // Latest status code.
75 Status status_;
76
77 // Invokes the corresponding callback on all registered observers.
78 void NotifyPolicyLoaded();
79 void NotifyStoreError();
80
81 private:
82 ObserverList<Observer, true> observers_;
83
84 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStore);
85 };
86
87 } // namespace policy
88
89 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698