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

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

Issue 10092010: Add CloudPolicyService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit. Created 8 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/policy/cloud_policy_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SERVICE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "base/callback_forward.h"
14 #include "base/compiler_specific.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "chrome/browser/policy/cloud_policy_client.h"
17 #include "chrome/browser/policy/cloud_policy_constants.h"
18 #include "chrome/browser/policy/cloud_policy_store.h"
19
20 namespace policy {
21
22 // Coordinates cloud policy handling, hosting the cloud policy client, fetching
23 // new policy, and updating the local policy cache when new policy becomes
24 // available.
25 class CloudPolicyService : public CloudPolicyClient::Observer,
26 public CloudPolicyStore::Observer {
27 public:
28 CloudPolicyService(scoped_ptr<CloudPolicyClient> client,
29 scoped_ptr<CloudPolicyStore> store);
30 virtual ~CloudPolicyService();
31
32 // Returns the domain that manages this user/device, according to the current
33 // policy blob. Empty if not managed/not available.
34 std::string ManagedBy() const;
35
36 // Refreshes policy. |callback| will be invoked after the operation completes
37 // or aborts because of errors.
38 void RefreshPolicy(const base::Closure& callback);
39
40 CloudPolicyClient* client() { return client_.get(); }
41 CloudPolicyStore* store() { return store_.get(); }
42
43 // CloudPolicyClient::Observer:
44 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
45 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE;
46 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE;
47
48 // CloudPolicyStore::Observer:
49 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
50 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
51
52 private:
53 // Invokes the refresh callbacks and clears refresh state.
54 void RefreshCompleted();
55
56 // The client used to talk to the cloud.
57 scoped_ptr<CloudPolicyClient> client_;
58
59 // Takes care of persisting and decoding cloud policy.
60 scoped_ptr<CloudPolicyStore> store_;
61
62 // Tracks the state of a pending refresh operation, if any.
63 enum {
64 // No refresh pending.
65 REFRESH_NONE,
66 // Policy fetch is pending.
67 REFRESH_POLICY_FETCH,
68 // Policy store is pending.
69 REFRESH_POLICY_STORE,
70 } refresh_state_;
71
72 // Callbacks to invoke upon policy refresh.
73 std::vector<base::Closure> refresh_callbacks_;
74
75 DISALLOW_COPY_AND_ASSIGN(CloudPolicyService);
76 };
77
78 } // namespace policy
79
80 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/policy/cloud_policy_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698