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

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

Issue 10919131: Break out base functionality of UserCloudPolicyManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
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_SERVICE_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
Joao da Silva 2012/09/07 12:44:13 nit: not used anymore
Mattias Nissler (ping if slow) 2012/09/07 13:12:59 Done.
15 #include "chrome/browser/policy/cloud_policy_client.h" 15 #include "chrome/browser/policy/cloud_policy_client.h"
16 #include "chrome/browser/policy/cloud_policy_constants.h" 16 #include "chrome/browser/policy/cloud_policy_constants.h"
17 #include "chrome/browser/policy/cloud_policy_store.h" 17 #include "chrome/browser/policy/cloud_policy_store.h"
18 18
19 namespace policy { 19 namespace policy {
20 20
21 // Coordinates cloud policy handling, hosting the cloud policy client, fetching 21 // Coordinates cloud policy handling, moving downloaded policy from the client
22 // new policy, and updating the local policy cache when new policy becomes 22 // to the store, and setting up client registrations from cached data in the
23 // available. 23 // store. Also coordinates actions on policy refresh triggers.
24 class CloudPolicyService : public CloudPolicyClient::Observer, 24 class CloudPolicyService : public CloudPolicyClient::Observer,
25 public CloudPolicyStore::Observer { 25 public CloudPolicyStore::Observer {
26 public: 26 public:
27 CloudPolicyService(scoped_ptr<CloudPolicyClient> client, 27 // |client| and |store| must remain valid for the object life time.
28 CloudPolicyStore* store); 28 CloudPolicyService(CloudPolicyClient* client, CloudPolicyStore* store);
29 virtual ~CloudPolicyService(); 29 virtual ~CloudPolicyService();
30 30
31 // Returns the domain that manages this user/device, according to the current 31 // Returns the domain that manages this user/device, according to the current
32 // policy blob. Empty if not managed/not available. 32 // policy blob. Empty if not managed/not available.
33 std::string ManagedBy() const; 33 std::string ManagedBy() const;
34 34
35 // Refreshes policy. |callback| will be invoked after the operation completes 35 // Refreshes policy. |callback| will be invoked after the operation completes
36 // or aborts because of errors. 36 // or aborts because of errors.
37 void RefreshPolicy(const base::Closure& callback); 37 void RefreshPolicy(const base::Closure& callback);
38 38
39 CloudPolicyClient* client() { return client_.get(); }
40 CloudPolicyStore* store() { return store_; }
41
42 // CloudPolicyClient::Observer: 39 // CloudPolicyClient::Observer:
43 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; 40 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
44 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; 41 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE;
45 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; 42 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE;
46 43
47 // CloudPolicyStore::Observer: 44 // CloudPolicyStore::Observer:
48 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; 45 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
49 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; 46 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
50 47
51 private: 48 private:
52 // Invokes the refresh callbacks and clears refresh state. 49 // Invokes the refresh callbacks and clears refresh state.
53 void RefreshCompleted(); 50 void RefreshCompleted();
54 51
55 // The client used to talk to the cloud. 52 // The client used to talk to the cloud.
56 scoped_ptr<CloudPolicyClient> client_; 53 CloudPolicyClient* client_;
57 54
58 // Takes care of persisting and decoding cloud policy. 55 // Takes care of persisting and decoding cloud policy.
59 CloudPolicyStore* store_; 56 CloudPolicyStore* store_;
60 57
61 // Tracks the state of a pending refresh operation, if any. 58 // Tracks the state of a pending refresh operation, if any.
62 enum { 59 enum {
63 // No refresh pending. 60 // No refresh pending.
64 REFRESH_NONE, 61 REFRESH_NONE,
65 // Policy fetch is pending. 62 // Policy fetch is pending.
66 REFRESH_POLICY_FETCH, 63 REFRESH_POLICY_FETCH,
67 // Policy store is pending. 64 // Policy store is pending.
68 REFRESH_POLICY_STORE, 65 REFRESH_POLICY_STORE,
69 } refresh_state_; 66 } refresh_state_;
70 67
71 // Callbacks to invoke upon policy refresh. 68 // Callbacks to invoke upon policy refresh.
72 std::vector<base::Closure> refresh_callbacks_; 69 std::vector<base::Closure> refresh_callbacks_;
73 70
74 DISALLOW_COPY_AND_ASSIGN(CloudPolicyService); 71 DISALLOW_COPY_AND_ASSIGN(CloudPolicyService);
75 }; 72 };
76 73
77 } // namespace policy 74 } // namespace policy
78 75
79 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_ 76 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698