OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_EXTERNAL_DATA_MANAGER_BASE_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_EXTERNAL_DATA_MANAGER_BASE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" |
| 13 |
| 14 namespace base { |
| 15 class SequencedTaskRunner; |
| 16 } |
| 17 |
| 18 namespace policy { |
| 19 |
| 20 class CloudExternalDataStore; |
| 21 struct PolicyDefinitionList; |
| 22 |
| 23 // Downloads, verifies, caches and retrieves external data referenced by |
| 24 // policies. |
| 25 // This is a common base class used by specializations for regular users and |
| 26 // device-local accounts. |
| 27 class CloudExternalDataManagerBase : public CloudExternalDataManager { |
| 28 public: |
| 29 // The |policy_definitions| are used to determine the maximum size that the |
| 30 // data referenced by each policy can have. All data download, verification, |
| 31 // caching and retrieval tasks are run via the |backend_task_runner|. |
| 32 CloudExternalDataManagerBase( |
| 33 const PolicyDefinitionList* policy_definitions, |
| 34 scoped_refptr<base::SequencedTaskRunner> backend_task_runner); |
| 35 virtual ~CloudExternalDataManagerBase(); |
| 36 |
| 37 // Allows downloaded external data to be cached in |external_data_store|. |
| 38 // Ownership of the store is taken. The store can be destroyed by calling |
| 39 // SetExternalDataStore(scoped_ptr<CloudExternalDataStore>()). Accesses to the |
| 40 // store are made via |backend_task_runner_| only. |
| 41 void SetExternalDataStore( |
| 42 scoped_ptr<CloudExternalDataStore> external_data_store); |
| 43 |
| 44 // CloudExternalDataManager: |
| 45 virtual void SetPolicyStore(CloudPolicyStore* policy_store) OVERRIDE; |
| 46 virtual void OnPolicyStoreLoaded() OVERRIDE; |
| 47 virtual void Connect( |
| 48 scoped_refptr<net::URLRequestContextGetter> request_context) OVERRIDE; |
| 49 virtual void Disconnect() OVERRIDE; |
| 50 virtual void Fetch( |
| 51 const std::string& policy, |
| 52 const ExternalDataFetcher::FetchCallback& callback) OVERRIDE; |
| 53 |
| 54 protected: |
| 55 friend class CouldExternalDataManagerBaseTest; |
| 56 |
| 57 // Try to download and cache all external data referenced by policies in |
| 58 // |policy_store_|. |
| 59 void FetchAll(); |
| 60 |
| 61 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; |
| 62 |
| 63 private: |
| 64 // The |backend_| handles all data download, verification, caching and |
| 65 // retrieval. It is instantiated on the UI thread but from then on, is |
| 66 // accessed via the |backend_task_runner_| only. |
| 67 class Backend; |
| 68 Backend* backend_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(CloudExternalDataManagerBase); |
| 71 }; |
| 72 |
| 73 } // namespace policy |
| 74 |
| 75 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_EXTERNAL_DATA_MANAGER_BASE_H_ |
OLD | NEW |