| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_COMPONENT_CLOUD_POLICY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_SERVICE_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_SERVICE_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // | 67 // |
| 68 // Download scheduling, validation and caching of policies are done via the | 68 // Download scheduling, validation and caching of policies are done via the |
| 69 // |backend_task_runner|, which must support file I/O. Network I/O is done via | 69 // |backend_task_runner|, which must support file I/O. Network I/O is done via |
| 70 // the |io_task_runner|. | 70 // the |io_task_runner|. |
| 71 // | 71 // |
| 72 // |request_context| is used by the background URLFetchers. | 72 // |request_context| is used by the background URLFetchers. |
| 73 ComponentCloudPolicyService( | 73 ComponentCloudPolicyService( |
| 74 Delegate* delegate, | 74 Delegate* delegate, |
| 75 SchemaRegistry* schema_registry, | 75 SchemaRegistry* schema_registry, |
| 76 CloudPolicyCore* core, | 76 CloudPolicyCore* core, |
| 77 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 77 scoped_ptr<ResourceCache> cache, | 78 scoped_ptr<ResourceCache> cache, |
| 79 #endif |
| 78 scoped_refptr<net::URLRequestContextGetter> request_context, | 80 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 79 scoped_refptr<base::SequencedTaskRunner> backend_task_runner, | 81 scoped_refptr<base::SequencedTaskRunner> backend_task_runner, |
| 80 scoped_refptr<base::SequencedTaskRunner> io_task_runner); | 82 scoped_refptr<base::SequencedTaskRunner> io_task_runner); |
| 81 virtual ~ComponentCloudPolicyService(); | 83 virtual ~ComponentCloudPolicyService(); |
| 82 | 84 |
| 83 // Returns true if |domain| is supported by the service. | 85 // Returns true if |domain| is supported by the service. |
| 84 static bool SupportsDomain(PolicyDomain domain); | 86 static bool SupportsDomain(PolicyDomain domain); |
| 85 | 87 |
| 86 // Returns true if the backend is initialized, and the initial policies and | 88 // Returns true if the backend is initialized, and the initial policies and |
| 87 // components are being served. | 89 // components are being served. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 102 // CloudPolicyStore::Observer implementation: | 104 // CloudPolicyStore::Observer implementation: |
| 103 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; | 105 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; |
| 104 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; | 106 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; |
| 105 | 107 |
| 106 // CloudPolicyClient::Observer implementation: | 108 // CloudPolicyClient::Observer implementation: |
| 107 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; | 109 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; |
| 108 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; | 110 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; |
| 109 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; | 111 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; |
| 110 | 112 |
| 111 private: | 113 private: |
| 114 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 112 class Backend; | 115 class Backend; |
| 113 | 116 |
| 114 void InitializeIfReady(); | 117 void InitializeIfReady(); |
| 115 void OnBackendInitialized(scoped_ptr<PolicyBundle> initial_policy); | 118 void OnBackendInitialized(scoped_ptr<PolicyBundle> initial_policy); |
| 116 void SetCurrentSchema(); | 119 void SetCurrentSchema(); |
| 117 void OnPolicyUpdated(scoped_ptr<PolicyBundle> policy); | 120 void OnPolicyUpdated(scoped_ptr<PolicyBundle> policy); |
| 118 | 121 |
| 119 Delegate* delegate_; | 122 Delegate* delegate_; |
| 120 SchemaRegistry* schema_registry_; | 123 SchemaRegistry* schema_registry_; |
| 121 CloudPolicyCore* core_; | 124 CloudPolicyCore* core_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 134 // The |backend_| handles all download scheduling, validation and caching of | 137 // The |backend_| handles all download scheduling, validation and caching of |
| 135 // policies. It is instantiated on the thread |this| runs on but after that, | 138 // policies. It is instantiated on the thread |this| runs on but after that, |
| 136 // must only be accessed and eventually destroyed via the | 139 // must only be accessed and eventually destroyed via the |
| 137 // |backend_task_runner_|. | 140 // |backend_task_runner_|. |
| 138 scoped_ptr<Backend> backend_; | 141 scoped_ptr<Backend> backend_; |
| 139 | 142 |
| 140 // The currently registered components for each policy domain. Used to | 143 // The currently registered components for each policy domain. Used to |
| 141 // determine which components changed when a new SchemaMap becomes | 144 // determine which components changed when a new SchemaMap becomes |
| 142 // available. | 145 // available. |
| 143 scoped_refptr<SchemaMap> current_schema_map_; | 146 scoped_refptr<SchemaMap> current_schema_map_; |
| 147 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 144 | 148 |
| 145 // Contains all the current policies for components. | 149 // Contains all the current policies for components. |
| 146 PolicyBundle policy_; | 150 PolicyBundle policy_; |
| 147 | 151 |
| 152 // Whether the backend has started initializing asynchronously. Used to |
| 153 // prevent double initialization, since both OnSchemaRegistryUpdated() and |
| 154 // OnStoreLoaded() can happen while the backend is initializing. |
| 155 bool started_loading_initial_policy_; |
| 156 |
| 148 // Whether the backend has been initialized with the initial credentials and | 157 // Whether the backend has been initialized with the initial credentials and |
| 149 // schemas, and this provider is serving the initial policies loaded from the | 158 // schemas, and this provider is serving the initial policies loaded from the |
| 150 // cache. | 159 // cache. |
| 151 bool loaded_initial_policy_; | 160 bool loaded_initial_policy_; |
| 152 | 161 |
| 153 // True if the backend currently has valid cloud policy credentials. This | 162 // True if the backend currently has valid cloud policy credentials. This |
| 154 // can go back to false if the user signs out, and back again to true if the | 163 // can go back to false if the user signs out, and back again to true if the |
| 155 // user signs in again. | 164 // user signs in again. |
| 156 bool is_registered_for_cloud_policy_; | 165 bool is_registered_for_cloud_policy_; |
| 157 | 166 |
| 158 base::WeakPtrFactory<ComponentCloudPolicyService> weak_ptr_factory_; | 167 base::WeakPtrFactory<ComponentCloudPolicyService> weak_ptr_factory_; |
| 159 | 168 |
| 160 DISALLOW_COPY_AND_ASSIGN(ComponentCloudPolicyService); | 169 DISALLOW_COPY_AND_ASSIGN(ComponentCloudPolicyService); |
| 161 }; | 170 }; |
| 162 | 171 |
| 163 } // namespace policy | 172 } // namespace policy |
| 164 | 173 |
| 165 #endif // CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_SERVICE_H_ | 174 #endif // CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_SERVICE_H_ |
| OLD | NEW |