| 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_CLOUD_EXTERNAL_DATA_MANAGER_BASE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_MANAGER_BASE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_MANAGER_BASE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_MANAGER_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 13 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 14 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
| 14 #include "components/policy/core/common/policy_details.h" | 15 #include "components/policy/core/common/policy_details.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class SequencedTaskRunner; | 18 class SequencedTaskRunner; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace policy { | 21 namespace policy { |
| 21 | 22 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 // caching and retrieval tasks are done via the |backend_task_runner|, which | 35 // caching and retrieval tasks are done via the |backend_task_runner|, which |
| 35 // must support file I/O. Network I/O is done via the |io_task_runner|. | 36 // must support file I/O. Network I/O is done via the |io_task_runner|. |
| 36 CloudExternalDataManagerBase( | 37 CloudExternalDataManagerBase( |
| 37 const GetChromePolicyDetailsCallback& get_policy_details, | 38 const GetChromePolicyDetailsCallback& get_policy_details, |
| 38 scoped_refptr<base::SequencedTaskRunner> backend_task_runner, | 39 scoped_refptr<base::SequencedTaskRunner> backend_task_runner, |
| 39 scoped_refptr<base::SequencedTaskRunner> io_task_runner); | 40 scoped_refptr<base::SequencedTaskRunner> io_task_runner); |
| 40 ~CloudExternalDataManagerBase() override; | 41 ~CloudExternalDataManagerBase() override; |
| 41 | 42 |
| 42 // Allows downloaded external data to be cached in |external_data_store|. | 43 // Allows downloaded external data to be cached in |external_data_store|. |
| 43 // Ownership of the store is taken. The store can be destroyed by calling | 44 // Ownership of the store is taken. The store can be destroyed by calling |
| 44 // SetExternalDataStore(scoped_ptr<CloudExternalDataStore>()). Accesses to the | 45 // SetExternalDataStore(std::unique_ptr<CloudExternalDataStore>()). Accesses |
| 46 // to the |
| 45 // store are made via |backend_task_runner_| only. | 47 // store are made via |backend_task_runner_| only. |
| 46 void SetExternalDataStore( | 48 void SetExternalDataStore( |
| 47 scoped_ptr<CloudExternalDataStore> external_data_store); | 49 std::unique_ptr<CloudExternalDataStore> external_data_store); |
| 48 | 50 |
| 49 // CloudExternalDataManager: | 51 // CloudExternalDataManager: |
| 50 void SetPolicyStore(CloudPolicyStore* policy_store) override; | 52 void SetPolicyStore(CloudPolicyStore* policy_store) override; |
| 51 void OnPolicyStoreLoaded() override; | 53 void OnPolicyStoreLoaded() override; |
| 52 void Connect( | 54 void Connect( |
| 53 scoped_refptr<net::URLRequestContextGetter> request_context) override; | 55 scoped_refptr<net::URLRequestContextGetter> request_context) override; |
| 54 void Disconnect() override; | 56 void Disconnect() override; |
| 55 void Fetch(const std::string& policy, | 57 void Fetch(const std::string& policy, |
| 56 const ExternalDataFetcher::FetchCallback& callback) override; | 58 const ExternalDataFetcher::FetchCallback& callback) override; |
| 57 | 59 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 | 73 |
| 72 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; | 74 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; |
| 73 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; | 75 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 // The |external_policy_data_fetcher_backend_| handles network I/O for the | 78 // The |external_policy_data_fetcher_backend_| handles network I/O for the |
| 77 // |backend_| because URLRequestContextGetter and URLFetchers cannot be | 79 // |backend_| because URLRequestContextGetter and URLFetchers cannot be |
| 78 // referenced from background threads. It is instantiated on the thread |this| | 80 // referenced from background threads. It is instantiated on the thread |this| |
| 79 // runs on but after that, must only be accessed and eventually destroyed via | 81 // runs on but after that, must only be accessed and eventually destroyed via |
| 80 // the |io_task_runner_|. | 82 // the |io_task_runner_|. |
| 81 scoped_ptr<ExternalPolicyDataFetcherBackend> | 83 std::unique_ptr<ExternalPolicyDataFetcherBackend> |
| 82 external_policy_data_fetcher_backend_; | 84 external_policy_data_fetcher_backend_; |
| 83 | 85 |
| 84 // The |backend_| handles all data download scheduling, verification, caching | 86 // The |backend_| handles all data download scheduling, verification, caching |
| 85 // and retrieval. It is instantiated on the thread |this| runs on but after | 87 // and retrieval. It is instantiated on the thread |this| runs on but after |
| 86 // that, must only be accessed and eventually destroyed via the | 88 // that, must only be accessed and eventually destroyed via the |
| 87 // |backend_task_runner_|. | 89 // |backend_task_runner_|. |
| 88 class Backend; | 90 class Backend; |
| 89 scoped_ptr<Backend> backend_; | 91 std::unique_ptr<Backend> backend_; |
| 90 | 92 |
| 91 DISALLOW_COPY_AND_ASSIGN(CloudExternalDataManagerBase); | 93 DISALLOW_COPY_AND_ASSIGN(CloudExternalDataManagerBase); |
| 92 }; | 94 }; |
| 93 | 95 |
| 94 } // namespace policy | 96 } // namespace policy |
| 95 | 97 |
| 96 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_MANAGER_BASE_H_ | 98 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CLOUD_EXTERNAL_DATA_MANAGER_BASE_H_ |
| OLD | NEW |