Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6923)

Unified Diff: chrome/browser/policy/asynchronous_policy_provider.cc

Issue 5562002: Refactor FileBasedPolicyProvider, introduce AsynchronousPolicyProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review feedback Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698