Index: chrome/browser/policy/asynchronous_policy_provider.cc |
diff --git a/chrome/browser/policy/asynchronous_policy_provider.cc b/chrome/browser/policy/asynchronous_policy_provider.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..176c25a0452a8ac031fa269a94d6ffb98a92974d |
--- /dev/null |
+++ b/chrome/browser/policy/asynchronous_policy_provider.cc |
@@ -0,0 +1,41 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/policy/asynchronous_policy_provider.h" |
+ |
+#include "base/task.h" |
+#include "chrome/browser/browser_thread.h" |
+#include "chrome/browser/policy/asynchronous_policy_loader.h" |
+ |
+namespace policy { |
+ |
+AsynchronousPolicyProvider::AsynchronousPolicyProvider( |
+ const PolicyDefinitionList* policy_list, |
+ scoped_refptr<AsynchronousPolicyLoader> loader) |
+ : ConfigurationPolicyProvider(policy_list), |
+ loader_(loader) { |
+ // TODO(danno): The weak pointer provider shouldn't be necessary. Instead, the |
+ // PrefStore should explicitly observe preference changes that are reported |
+ // during the policy change. |
+ loader_->SetProvider(AsWeakPtr()); |
+ loader_->Init(); |
+} |
+ |
+AsynchronousPolicyProvider::~AsynchronousPolicyProvider() { |
+ loader_->Stop(); |
+} |
+ |
+bool AsynchronousPolicyProvider::Provide( |
+ ConfigurationPolicyStoreInterface* store) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ DCHECK(loader_->policy()); |
+ DecodePolicyValueTree(loader_->policy(), store); |
+ return true; |
+} |
+ |
+scoped_refptr<AsynchronousPolicyLoader> AsynchronousPolicyProvider::loader() { |
+ return loader_; |
+} |
+ |
+} // namespace policy |