Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / device_local_account_external_data_manager.h
blobebfe8ec3de4fe8f30f80dc8dead2ce286717ec43
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_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_MANAGER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h"
14 #include "components/policy/core/common/policy_details.h"
16 namespace base {
17 class SequencedTaskRunner;
20 namespace policy {
22 class ResourceCache;
24 // Downloads, verifies, caches and retrieves external data referenced by
25 // policies.
26 // This is the implementation for device-local accounts on Chrome OS.
27 // The manager is created by the DeviceLocalAccountExternalDataService and must
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
30 // either the service or a DeviceLocalAccountPolicyProvider references it. This
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
33 // exists for the account. The manager is only destroyed when neither service
34 // nor provider reference it anymore.
35 class DeviceLocalAccountExternalDataManager
36 : public CloudExternalDataManagerBase,
37 public base::RefCounted<DeviceLocalAccountExternalDataManager> {
38 private:
39 friend class DeviceLocalAccountExternalDataService;
40 friend class base::RefCounted<DeviceLocalAccountExternalDataManager>;
42 // |get_policy_details| is used to determine the maximum size that the
43 // data referenced by each policy can have. Download scheduling, verification,
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
46 // manager is responsible for external data references by policies in
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
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.
51 DeviceLocalAccountExternalDataManager(
52 const std::string& account_id,
53 const GetChromePolicyDetailsCallback& get_policy_details,
54 scoped_refptr<base::SequencedTaskRunner> backend_task_runner,
55 scoped_refptr<base::SequencedTaskRunner> io_task_runner,
56 ResourceCache* resource_cache);
57 ~DeviceLocalAccountExternalDataManager() override;
59 // CloudExternalDataManagerBase:
60 void OnPolicyStoreLoaded() override;
62 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountExternalDataManager);
65 } // namespace policy
67 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_MANAGER_H_