device_local_account_external_data_manager.cc revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
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#include "chrome/browser/chromeos/policy/device_local_account_external_data_manager.h"
6
7#include "base/memory/scoped_ptr.h"
8#include "base/sequenced_task_runner.h"
9#include "chrome/browser/chromeos/policy/cloud_external_data_store.h"
10#include "chrome/browser/chromeos/policy/device_local_account_external_data_service.h"
11#include "components/policy/core/common/cloud/resource_cache.h"
12#include "policy/policy_constants.h"
13
14namespace policy {
15
16DeviceLocalAccountExternalDataManager::DeviceLocalAccountExternalDataManager(
17    const std::string& account_id,
18    const GetChromePolicyDetailsCallback& get_policy_details,
19    scoped_refptr<base::SequencedTaskRunner> backend_task_runner,
20    scoped_refptr<base::SequencedTaskRunner> io_task_runner,
21    ResourceCache* resource_cache)
22    : CloudExternalDataManagerBase(get_policy_details,
23                                   backend_task_runner,
24                                   io_task_runner) {
25  SetExternalDataStore(make_scoped_ptr(new CloudExternalDataStore(
26      account_id, backend_task_runner, resource_cache)));
27}
28
29DeviceLocalAccountExternalDataManager::
30    ~DeviceLocalAccountExternalDataManager() {
31  SetExternalDataStore(scoped_ptr<CloudExternalDataStore>());
32}
33
34void DeviceLocalAccountExternalDataManager::OnPolicyStoreLoaded() {
35  CloudExternalDataManagerBase::OnPolicyStoreLoaded();
36  // Proactively try to download and cache all external data referenced by
37  // policies.
38  FetchAll();
39}
40
41}  // namespace policy
42