1 // Copyright 2018 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_CHROMEOS_POLICY_DEVICE_POLICY_CLOUD_EXTERNAL_DATA_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CLOUD_EXTERNAL_DATA_MANAGER_H_ 7 8 #include <memory> 9 10 #include "base/files/file_path.h" 11 #include "base/macros.h" 12 #include "base/memory/scoped_refptr.h" 13 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h" 14 #include "components/policy/core/common/policy_details.h" 15 16 namespace base { 17 class SequencedTaskRunner; 18 } 19 20 namespace policy { 21 22 class CloudPolicyStore; 23 class ResourceCache; 24 25 // Downloads, verifies and caches external data referenced by policies. 26 // This is the implementation for device policy external data. 27 class DevicePolicyCloudExternalDataManager 28 : public CloudExternalDataManagerBase { 29 public: 30 // |get_policy_details| is used to determine the maximum size that the 31 // data referenced by each policy can have. Download scheduling, verification, 32 // caching and retrieval tasks are done via the |backend_task_runner|, which 33 // must support file I/O. |resource_cache| is used to construct a data store 34 // which caches downloaded blobs on disk. 35 DevicePolicyCloudExternalDataManager( 36 const GetChromePolicyDetailsCallback& get_policy_details, 37 scoped_refptr<base::SequencedTaskRunner> backend_task_runner, 38 const base::FilePath& cache_path, 39 CloudPolicyStore* policy_store); 40 ~DevicePolicyCloudExternalDataManager() override; 41 42 // Sets the cache maximum size for testing. 43 // It's used to avoid creating big data in tests. 44 static void SetCacheMaxSizeForTesting(int64_t cache_max_size); 45 46 private: 47 // Cache used by the data store. Must outlive the data store. 48 std::unique_ptr<ResourceCache> resource_cache_; 49 50 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCloudExternalDataManager); 51 }; 52 53 } // namespace policy 54 55 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CLOUD_EXTERNAL_DATA_MANAGER_H_ 56