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

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: rebase 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
« no previous file with comments | « chrome/browser/policy/async_policy_loader.h ('k') | chrome/browser/policy/async_policy_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ba88ce7b8f2130e596fcb972dc89f6c2a3abd433 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,29 +58,23 @@ 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();
- return Load();
+ schema_map_ = schema_map;
+ scoped_ptr<PolicyBundle> bundle(Load());
+ // Filter out mismatching policies.
+ schema_map_->FilterBundle(bundle.get());
+ return bundle.Pass();
}
void AsyncPolicyLoader::Init(const UpdateCallback& update_callback) {
@@ -101,6 +94,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 +126,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;
« no previous file with comments | « chrome/browser/policy/async_policy_loader.h ('k') | chrome/browser/policy/async_policy_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698