| OLD | NEW |
| (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_CORE_H_ | |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CORE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/prefs/public/pref_member.h" | |
| 13 #include "chrome/browser/policy/cloud_policy_constants.h" | |
| 14 | |
| 15 class PrefService; | |
| 16 | |
| 17 namespace policy { | |
| 18 | |
| 19 class CloudPolicyClient; | |
| 20 class CloudPolicyRefreshScheduler; | |
| 21 class CloudPolicyService; | |
| 22 class CloudPolicyStore; | |
| 23 | |
| 24 // CloudPolicyCore glues together the ingredients that are essential for | |
| 25 // obtaining a fully-functional cloud policy system: CloudPolicyClient and | |
| 26 // CloudPolicyStore, which are responsible for fetching policy from the cloud | |
| 27 // and storing it locally, respectively, as well as a CloudPolicyService | |
| 28 // instance that moves data between the two former components, and | |
| 29 // CloudPolicyRefreshScheduler which triggers periodic refreshes. | |
| 30 class CloudPolicyCore { | |
| 31 public: | |
| 32 CloudPolicyCore(const PolicyNamespaceKey& policy_ns_key, | |
| 33 CloudPolicyStore* store); | |
| 34 ~CloudPolicyCore(); | |
| 35 | |
| 36 CloudPolicyClient* client() { return client_.get(); } | |
| 37 const CloudPolicyClient* client() const { return client_.get(); } | |
| 38 | |
| 39 CloudPolicyStore* store() { return store_; } | |
| 40 const CloudPolicyStore* store() const { return store_; } | |
| 41 | |
| 42 CloudPolicyService* service() { return service_.get(); } | |
| 43 const CloudPolicyService* service() const { return service_.get(); } | |
| 44 | |
| 45 CloudPolicyRefreshScheduler* refresh_scheduler() { | |
| 46 return refresh_scheduler_.get(); | |
| 47 } | |
| 48 const CloudPolicyRefreshScheduler* refresh_scheduler() const { | |
| 49 return refresh_scheduler_.get(); | |
| 50 } | |
| 51 | |
| 52 // Initializes the cloud connection. | |
| 53 void Connect(scoped_ptr<CloudPolicyClient> client); | |
| 54 | |
| 55 // Shuts down the cloud connection. | |
| 56 void Disconnect(); | |
| 57 | |
| 58 // Starts a refresh scheduler in case none is running yet. | |
| 59 void StartRefreshScheduler(); | |
| 60 | |
| 61 // Watches the pref named |refresh_pref_name| in |pref_service| and adjusts | |
| 62 // |refresh_scheduler_|'s refresh delay accordingly. | |
| 63 void TrackRefreshDelayPref(PrefService* pref_service, | |
| 64 const std::string& refresh_pref_name); | |
| 65 | |
| 66 private: | |
| 67 // Updates the refresh scheduler on refresh delay changes. | |
| 68 void UpdateRefreshDelayFromPref(); | |
| 69 | |
| 70 PolicyNamespaceKey policy_ns_key_; | |
| 71 CloudPolicyStore* store_; | |
| 72 scoped_ptr<CloudPolicyClient> client_; | |
| 73 scoped_ptr<CloudPolicyService> service_; | |
| 74 scoped_ptr<CloudPolicyRefreshScheduler> refresh_scheduler_; | |
| 75 scoped_ptr<IntegerPrefMember> refresh_delay_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCore); | |
| 78 }; | |
| 79 | |
| 80 } // namespace policy | |
| 81 | |
| 82 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CORE_H_ | |
| OLD | NEW |