| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_MANAGE
R_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_MANAGE
R_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_MANAGE
R_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_MANAGE
R_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h" | 13 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h" |
| 14 #include "components/policy/core/common/policy_details.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace policy { | 20 namespace policy { |
| 20 | 21 |
| 21 struct PolicyDefinitionList; | |
| 22 class ResourceCache; | 22 class ResourceCache; |
| 23 | 23 |
| 24 // Downloads, verifies, caches and retrieves external data referenced by | 24 // Downloads, verifies, caches and retrieves external data referenced by |
| 25 // policies. | 25 // policies. |
| 26 // This is the implementation for device-local accounts on Chrome OS. | 26 // This is the implementation for device-local accounts on Chrome OS. |
| 27 // The manager is created by the DeviceLocalAccountExternalDataService and must | 27 // The manager is created by the DeviceLocalAccountExternalDataService and must |
| 28 // not outlive it because the |resource_cache| is owned by the service. However, | 28 // not outlive it because the |resource_cache| is owned by the service. However, |
| 29 // the service is not the manager's sole owner: The manager lives as long as | 29 // the service is not the manager's sole owner: The manager lives as long as |
| 30 // either the service or a DeviceLocalAccountPolicyProvider references it. This | 30 // either the service or a DeviceLocalAccountPolicyProvider references it. This |
| 31 // is necessary because a device-local account can be removed from policy (thus | 31 // is necessary because a device-local account can be removed from policy (thus |
| 32 // removing it from the service) while a session is in progress and a provider | 32 // removing it from the service) while a session is in progress and a provider |
| 33 // exists for the account. The manager is only destroyed when neither service | 33 // exists for the account. The manager is only destroyed when neither service |
| 34 // nor provider reference it anymore. | 34 // nor provider reference it anymore. |
| 35 class DeviceLocalAccountExternalDataManager | 35 class DeviceLocalAccountExternalDataManager |
| 36 : public CloudExternalDataManagerBase, | 36 : public CloudExternalDataManagerBase, |
| 37 public base::RefCounted<DeviceLocalAccountExternalDataManager> { | 37 public base::RefCounted<DeviceLocalAccountExternalDataManager> { |
| 38 private: | 38 private: |
| 39 friend class DeviceLocalAccountExternalDataService; | 39 friend class DeviceLocalAccountExternalDataService; |
| 40 friend class base::RefCounted<DeviceLocalAccountExternalDataManager>; | 40 friend class base::RefCounted<DeviceLocalAccountExternalDataManager>; |
| 41 | 41 |
| 42 // The |policy_definitions| are used to determine the maximum size that the | 42 // |get_policy_details| is used to determine the maximum size that the |
| 43 // data referenced by each policy can have. Download scheduling, verification, | 43 // data referenced by each policy can have. Download scheduling, verification, |
| 44 // caching and retrieval tasks are done via the |backend_task_runner|, which | 44 // caching and retrieval tasks are done via the |backend_task_runner|, which |
| 45 // must support file I/O. Network I/O is done via the |io_task_runner|. The | 45 // must support file I/O. Network I/O is done via the |io_task_runner|. The |
| 46 // manager is responsible for external data references by policies in | 46 // manager is responsible for external data references by policies in |
| 47 // |policy_store|. Downloaded external data is stored in the |resource_cache|. | 47 // |policy_store|. Downloaded external data is stored in the |resource_cache|. |
| 48 // The data is keyed by |account_id|, allowing one cache to be shared by any | 48 // The data is keyed by |account_id|, allowing one cache to be shared by any |
| 49 // number of accounts. To ensure synchronization of operations on the shared | 49 // number of accounts. To ensure synchronization of operations on the shared |
| 50 // cache, all its users must access the cache via |backend_task_runner| only. | 50 // cache, all its users must access the cache via |backend_task_runner| only. |
| 51 DeviceLocalAccountExternalDataManager( | 51 DeviceLocalAccountExternalDataManager( |
| 52 const std::string& account_id, | 52 const std::string& account_id, |
| 53 const PolicyDefinitionList* policy_definitions, | 53 const GetChromePolicyDetailsCallback& get_policy_details, |
| 54 scoped_refptr<base::SequencedTaskRunner> backend_task_runner, | 54 scoped_refptr<base::SequencedTaskRunner> backend_task_runner, |
| 55 scoped_refptr<base::SequencedTaskRunner> io_task_runner, | 55 scoped_refptr<base::SequencedTaskRunner> io_task_runner, |
| 56 ResourceCache* resource_cache); | 56 ResourceCache* resource_cache); |
| 57 virtual ~DeviceLocalAccountExternalDataManager(); | 57 virtual ~DeviceLocalAccountExternalDataManager(); |
| 58 | 58 |
| 59 // CloudExternalDataManagerBase: | 59 // CloudExternalDataManagerBase: |
| 60 virtual void OnPolicyStoreLoaded() OVERRIDE; | 60 virtual void OnPolicyStoreLoaded() OVERRIDE; |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountExternalDataManager); | 62 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountExternalDataManager); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 } // namespace policy | 65 } // namespace policy |
| 66 | 66 |
| 67 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_MAN
AGER_H_ | 67 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_MAN
AGER_H_ |
| OLD | NEW |