Home | History | Annotate | Download | only in policy
      1 // Copyright (c) 2010 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/policy/asynchronous_policy_provider.h"
      6 
      7 #include "chrome/browser/policy/asynchronous_policy_loader.h"
      8 
      9 namespace policy {
     10 
     11 AsynchronousPolicyProvider::AsynchronousPolicyProvider(
     12     const PolicyDefinitionList* policy_list,
     13     scoped_refptr<AsynchronousPolicyLoader> loader)
     14     : ConfigurationPolicyProvider(policy_list),
     15       loader_(loader) {
     16   loader_->Init();
     17 }
     18 
     19 AsynchronousPolicyProvider::~AsynchronousPolicyProvider() {
     20   DCHECK(CalledOnValidThread());
     21   loader_->Stop();
     22 }
     23 
     24 bool AsynchronousPolicyProvider::Provide(
     25     ConfigurationPolicyStoreInterface* store) {
     26   DCHECK(CalledOnValidThread());
     27   DCHECK(loader_->policy());
     28   ApplyPolicyValueTree(loader_->policy(), store);
     29   return true;
     30 }
     31 
     32 void AsynchronousPolicyProvider::AddObserver(
     33     ConfigurationPolicyProvider::Observer* observer) {
     34   loader_->AddObserver(observer);
     35 }
     36 
     37 void AsynchronousPolicyProvider::RemoveObserver(
     38     ConfigurationPolicyProvider::Observer* observer) {
     39   loader_->RemoveObserver(observer);
     40 }
     41 
     42 scoped_refptr<AsynchronousPolicyLoader> AsynchronousPolicyProvider::loader() {
     43   return loader_;
     44 }
     45 
     46 }  // namespace policy
     47