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

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: Address comments. 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
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 // Returns current status.
37 CloudPolicyStatus GetStatus() const;
Joao da Silva 2012/05/22 22:01:44 This is not defined, is it still needed?
Mattias Nissler (ping if slow) 2012/05/24 10:12:25 Removed, see other comment for details.
38
39 // Refreshes policy. |callback| will be invoked after the operation completes
40 // or aborts because of errors.
41 void RefreshPolicy(const base::Closure& callback);
42
43 CloudPolicyClient* client() { return client_.get(); }
44 CloudPolicyStore* store() { return store_.get(); }
45
46 // CloudPolicyClient::Observer:
47 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
48 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE;
49 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE;
50
51 // CloudPolicyStore::Observer:
52 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
53 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
54
55 private:
56 // Invokes the refresh callbacks and clears refresh state.
57 void RefreshCompleted();
58
59 // The client used to talk to the cloud.
60 scoped_ptr<CloudPolicyClient> client_;
61
62 // Takes care of persisting and decoding cloud policy.
63 scoped_ptr<CloudPolicyStore> store_;
64
65 // Tracks the state of a pending refresh operation, if any.
66 enum {
67 // No refresh pending.
68 REFRESH_NONE,
69 // Policy fetch is pending.
70 REFRESH_POLICY_FETCH,
71 // Policy store is pending.
72 REFRESH_POLICY_STORE,
73 } refresh_state_;
74
75 // Callbacks to invoke upon policy refresh.
76 std::vector<base::Closure> refresh_callbacks_;
77
78 DISALLOW_COPY_AND_ASSIGN(CloudPolicyService);
79 };
80
81 } // namespace policy
82
83 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698