- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / policy / cloud / user_cloud_policy_store_base.h
1 // Copyright (c) 2012 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_USER_CLOUD_POLICY_STORE_BASE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_STORE_BASE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
15 #include "chrome/browser/policy/cloud/cloud_policy_validator.h"
16
17 namespace base {
18 class SequencedTaskRunner;
19 }
20
21 namespace policy {
22
23 // Base class that implements common cross-platform UserCloudPolicyStore
24 // functionality.
25 class UserCloudPolicyStoreBase : public CloudPolicyStore {
26  public:
27   explicit UserCloudPolicyStoreBase(
28       scoped_refptr<base::SequencedTaskRunner> background_task_runner);
29   virtual ~UserCloudPolicyStoreBase();
30
31  protected:
32   // Creates a validator configured to validate a user policy. The caller owns
33   // the resulting object until StartValidation() is invoked.
34   scoped_ptr<UserCloudPolicyValidator> CreateValidator(
35       scoped_ptr<enterprise_management::PolicyFetchResponse> policy,
36       CloudPolicyValidatorBase::ValidateTimestampOption option);
37
38   // Sets |policy_data| and |payload| as the active policy.
39   void InstallPolicy(
40       scoped_ptr<enterprise_management::PolicyData> policy_data,
41       scoped_ptr<enterprise_management::CloudPolicySettings> payload);
42
43   scoped_refptr<base::SequencedTaskRunner> background_task_runner() const {
44     return background_task_runner_;
45   }
46
47  private:
48   // Task runner for background file operations.
49   scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
50
51   DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreBase);
52 };
53
54 }  // namespace policy
55
56 #endif  // CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_STORE_BASE_H_