Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / policy / device_local_account_external_data_service.h
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_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_SERVICE_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/browser/chromeos/policy/device_local_account_external_data_manager.h"
16 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
17 #include "components/policy/core/common/cloud/resource_cache.h"
18
19 namespace base {
20 class SequencedTaskRunner;
21 }
22
23 namespace policy {
24
25 class CloudPolicyStore;
26
27 // Provides DeviceLocalAccountExternalDataManagers for all device-local
28 // accounts. This class owns the |resource_cache_| that the managers share.
29 class DeviceLocalAccountExternalDataService
30     : public DeviceLocalAccountPolicyService::Observer {
31  public:
32   DeviceLocalAccountExternalDataService(
33       DeviceLocalAccountPolicyService* parent,
34       scoped_refptr<base::SequencedTaskRunner> backend_task_runner,
35       scoped_refptr<base::SequencedTaskRunner> io_task_runner);
36   virtual ~DeviceLocalAccountExternalDataService();
37
38   // DeviceLocalAccountPolicyService::Observer:
39   virtual void OnPolicyUpdated(const std::string& user_id) override;
40   virtual void OnDeviceLocalAccountsChanged() override;
41
42   scoped_refptr<DeviceLocalAccountExternalDataManager>
43       GetExternalDataManager(const std::string& account_id,
44                              CloudPolicyStore* policy_store);
45
46  private:
47   typedef std::map<std::string,
48                    scoped_refptr<DeviceLocalAccountExternalDataManager> >
49       ExternalDataManagerMap;
50
51   DeviceLocalAccountPolicyService* parent_;
52   scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
53   scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
54   scoped_ptr<ResourceCache> resource_cache_;
55
56   ExternalDataManagerMap external_data_managers_;
57
58   DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountExternalDataService);
59 };
60
61 }  // namespace policy
62
63 #endif  // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA_SERVICE_H_