Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / user_cloud_external_data_manager.h
blobb7dfa0f74e7e5fd13b81e9bae6ab606c336d0043
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_EXTERNAL_DATA_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_EXTERNAL_DATA_MANAGER_H_
8 #include "base/basictypes.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h"
12 #include "components/policy/core/common/policy_details.h"
14 namespace base {
15 class SequencedTaskRunner;
18 namespace policy {
20 class CloudPolicyStore;
21 class ResourceCache;
23 // Downloads, verifies, caches and retrieves external data referenced by
24 // policies.
25 // This is the implementation for regular users on Chrome OS. The code would
26 // work on desktop platforms as well but for now, is used on Chrome OS only
27 // because no other platform has policies referencing external data.
28 class UserCloudExternalDataManager : 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. Network I/O is done via the |io_task_runner|. The
34 // manager is responsible for external data references by policies in
35 // |policy_store|.
36 UserCloudExternalDataManager(
37 const GetChromePolicyDetailsCallback& get_policy_details,
38 scoped_refptr<base::SequencedTaskRunner> backend_task_runner,
39 scoped_refptr<base::SequencedTaskRunner> io_task_runner,
40 const base::FilePath& cache_path,
41 CloudPolicyStore* policy_store);
42 ~UserCloudExternalDataManager() override;
44 private:
45 // Cache used to store downloaded external data. The |resource_cache_| is
46 // owned by the manager but its destruction must be handled with care:
47 // * The manager owns a |backend_| which owns an |external_data_store_| which
48 // uses the |resource_cache_|. The |external_data_store_| must be destroyed
49 // before the |resource_cache_|.
50 // * After construction, |backend_|, |external_data_store_| and
51 // |resource_cache_| can only be accessed through the
52 // |backend_task_runner_|.
54 // It follows that in order to destroy |resource_cache_|, the manager must
55 // take the following steps:
56 // * Post a task to the |backend_task_runner_| that will tell the |backend_|
57 // to destroy the |external_data_store_|.
58 // * Post a task to the |backend_task_runner_| that will destroy the
59 // |resource_cache_|.
60 // Because of this destruction sequence, a scoped_ptr cannot be used.
61 ResourceCache* resource_cache_;
63 DISALLOW_COPY_AND_ASSIGN(UserCloudExternalDataManager);
66 } // namespace policy
68 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_EXTERNAL_DATA_MANAGER_H_