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

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: merge with TOT 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..709568ffd9d15217d0c4a227a948cb4a6d9dcb1a
--- /dev/null
+++ b/chrome/browser/policy/asynchronous_policy_provider.cc
@@ -0,0 +1,42 @@
+// 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 "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): This explicit registration of the provider shouldn't be
+ // necessary. Instead, the PrefStore should explicitly observe preference
+ // changes that are reported during the policy change.
+ loader_->SetProvider(this);
+ loader_->Init();
+}
+
+AsynchronousPolicyProvider::~AsynchronousPolicyProvider() {
+ DCHECK(CalledOnValidThread());
+ loader_->Stop();
+ loader_->SetProvider(NULL);
+}
+
+bool AsynchronousPolicyProvider::Provide(
+ ConfigurationPolicyStoreInterface* store) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(loader_->policy());
+ DecodePolicyValueTree(loader_->policy(), store);
+ return true;
+}
+
+scoped_refptr<AsynchronousPolicyLoader> AsynchronousPolicyProvider::loader() {
+ return loader_;
+}
+
+} // namespace policy
« no previous file with comments | « chrome/browser/policy/asynchronous_policy_provider.h ('k') | chrome/browser/policy/asynchronous_policy_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698