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

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

Issue 56623005: Policy providers all get a SchemaRegistry to work with. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-policy-schema-9-purge-with-callback
Patch Set: Fixed mac tests Created 7 years, 1 month 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/async_policy_loader.cc
diff --git a/chrome/browser/policy/async_policy_loader.cc b/chrome/browser/policy/async_policy_loader.cc
index 05c1bb09537f80fb4df33e1b208dedc0ca4d2815..ce76f13be23d6b39a21d38ebc95524a64fc37874 100644
--- a/chrome/browser/policy/async_policy_loader.cc
+++ b/chrome/browser/policy/async_policy_loader.cc
@@ -8,7 +8,6 @@
#include "base/location.h"
#include "base/sequenced_task_runner.h"
#include "chrome/browser/policy/policy_bundle.h"
-#include "chrome/browser/policy/policy_domain_descriptor.h"
using base::Time;
using base::TimeDelta;
@@ -35,8 +34,8 @@ AsyncPolicyLoader::AsyncPolicyLoader(
AsyncPolicyLoader::~AsyncPolicyLoader() {}
-base::Time AsyncPolicyLoader::LastModificationTime() {
- return base::Time();
+Time AsyncPolicyLoader::LastModificationTime() {
+ return Time();
}
void AsyncPolicyLoader::Reload(bool force) {
@@ -59,28 +58,19 @@ void AsyncPolicyLoader::Reload(bool force) {
}
// Filter out mismatching policies.
- for (DescriptorMap::iterator it = descriptor_map_.begin();
- it != descriptor_map_.end(); ++it) {
- it->second->FilterBundle(bundle.get());
- }
+ schema_map_->FilterBundle(bundle.get());
update_callback_.Run(bundle.Pass());
ScheduleNextReload(TimeDelta::FromSeconds(kReloadIntervalSeconds));
}
-void AsyncPolicyLoader::RegisterPolicyDomain(
- scoped_refptr<const PolicyDomainDescriptor> descriptor) {
- if (descriptor->domain() != POLICY_DOMAIN_CHROME) {
- descriptor_map_[descriptor->domain()] = descriptor;
- Reload(true);
- }
-}
-
-scoped_ptr<PolicyBundle> AsyncPolicyLoader::InitialLoad() {
+scoped_ptr<PolicyBundle> AsyncPolicyLoader::InitialLoad(
+ const scoped_refptr<SchemaMap>& schema_map) {
// This is the first load, early during startup. Use this to record the
// initial |last_modification_time_|, so that potential changes made before
// installing the watches can be detected.
last_modification_time_ = LastModificationTime();
+ schema_map_ = schema_map;
return Load();
}
@@ -101,6 +91,12 @@ void AsyncPolicyLoader::Init(const UpdateCallback& update_callback) {
ScheduleNextReload(TimeDelta::FromSeconds(kReloadIntervalSeconds));
}
+void AsyncPolicyLoader::RefreshPolicies(scoped_refptr<SchemaMap> schema_map) {
+ DCHECK(task_runner_->RunsTasksOnCurrentThread());
+ schema_map_ = schema_map;
+ Reload(true);
+}
+
void AsyncPolicyLoader::ScheduleNextReload(TimeDelta delay) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
weak_factory_.InvalidateWeakPtrs();
@@ -127,7 +123,7 @@ bool AsyncPolicyLoader::IsSafeToReload(const Time& now, TimeDelta* delay) {
}
// Check whether the settle interval has elapsed.
- const base::TimeDelta age = now - last_modification_clock_;
+ const TimeDelta age = now - last_modification_clock_;
if (age < kSettleInterval) {
*delay = kSettleInterval - age;
return false;

Powered by Google App Engine
This is Rietveld 408576698