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 COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_CLOUD_POLICY_STORE_BASE_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_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 "components/policy/core/common/cloud/cloud_policy_store.h" 15 #include "components/policy/core/common/cloud/cloud_policy_validator.h" 16 #include "components/policy/policy_export.h" 17 18 namespace base { 19 class SequencedTaskRunner; 20 } 21 22 namespace policy { 23 24 // Base class that implements common cross-platform UserCloudPolicyStore 25 // functionality. 26 class POLICY_EXPORT UserCloudPolicyStoreBase : public CloudPolicyStore { 27 public: 28 explicit UserCloudPolicyStoreBase( 29 scoped_refptr<base::SequencedTaskRunner> background_task_runner); 30 virtual ~UserCloudPolicyStoreBase(); 31 32 protected: 33 // Creates a validator configured to validate a user policy. The caller owns 34 // the resulting object until StartValidation() is invoked. 35 scoped_ptr<UserCloudPolicyValidator> CreateValidator( 36 scoped_ptr<enterprise_management::PolicyFetchResponse> policy, 37 CloudPolicyValidatorBase::ValidateTimestampOption option); 38 39 // Sets |policy_data| and |payload| as the active policy. 40 void InstallPolicy( 41 scoped_ptr<enterprise_management::PolicyData> policy_data, 42 scoped_ptr<enterprise_management::CloudPolicySettings> payload); 43 44 scoped_refptr<base::SequencedTaskRunner> background_task_runner() const { 45 return background_task_runner_; 46 } 47 48 private: 49 // Task runner for background file operations. 50 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; 51 52 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreBase); 53 }; 54 55 } // namespace policy 56 57 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_CLOUD_POLICY_STORE_BASE_H_ 58