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

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

Issue 8586030: Added ConfigurationPolicyProvider::RefreshPolicies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed win build Created 9 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/asynchronous_policy_loader.cc
diff --git a/chrome/browser/policy/asynchronous_policy_loader.cc b/chrome/browser/policy/asynchronous_policy_loader.cc
index 1a55b66e512b7a65582599a61daca57a3e199450..e58d742d2017cf6f89a199eddc1f26c7ae3d086c 100644
--- a/chrome/browser/policy/asynchronous_policy_loader.cc
+++ b/chrome/browser/policy/asynchronous_policy_loader.cc
@@ -21,8 +21,8 @@ AsynchronousPolicyLoader::AsynchronousPolicyLoader(
origin_loop_(MessageLoop::current()),
stopped_(false) {}
-void AsynchronousPolicyLoader::Init(const base::Closure& callback) {
- updates_callback_ = callback;
+void AsynchronousPolicyLoader::Init(const base::Closure& default_callback) {
+ default_callback_ = default_callback;
policy_.reset(delegate_->Load());
// Initialization can happen early when the file thread is not yet available,
// but the subclass of the loader must do some of their initialization on the
@@ -48,10 +48,13 @@ void AsynchronousPolicyLoader::Stop() {
AsynchronousPolicyLoader::~AsynchronousPolicyLoader() {
}
-void AsynchronousPolicyLoader::Reload(bool force) {
+void AsynchronousPolicyLoader::Reload(const base::Closure& callback,
+ bool force) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
if (delegate_.get()) {
- PostUpdatePolicyTask(delegate_->Load());
+ PostUpdatePolicyTask(callback, delegate_->Load());
+ } else {
+ PostUpdatePolicyTask(callback, NULL);
}
}
@@ -60,6 +63,7 @@ void AsynchronousPolicyLoader::CancelReloadTask() {
}
void AsynchronousPolicyLoader::ScheduleReloadTask(
+ const base::Closure& callback,
const base::TimeDelta& delay) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
@@ -67,8 +71,10 @@ void AsynchronousPolicyLoader::ScheduleReloadTask(
BrowserThread::PostDelayedTask(
BrowserThread::FILE, FROM_HERE,
- base::Bind(&AsynchronousPolicyLoader::ReloadFromTask,
- weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&AsynchronousPolicyLoader::Reload,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback,
+ false),
delay.InMilliseconds());
}
@@ -76,12 +82,7 @@ void AsynchronousPolicyLoader::ScheduleFallbackReloadTask() {
// As a safeguard in case that the load delegate failed to timely notice a
// change in policy, schedule a reload task that'll make us recheck after a
// reasonable interval.
- ScheduleReloadTask(reload_interval_);
-}
-
-void AsynchronousPolicyLoader::ReloadFromTask() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- Reload(false);
+ ScheduleReloadTask(default_callback_, reload_interval_);
}
void AsynchronousPolicyLoader::InitOnFileThread() {
@@ -93,19 +94,22 @@ void AsynchronousPolicyLoader::StopOnFileThread() {
}
void AsynchronousPolicyLoader::PostUpdatePolicyTask(
+ const base::Closure& callback,
DictionaryValue* new_policy) {
// TODO(joaodasilva): make the callback own |new_policy|.
origin_loop_->PostTask(
FROM_HERE,
- base::Bind(&AsynchronousPolicyLoader::UpdatePolicy, this, new_policy));
+ base::Bind(&AsynchronousPolicyLoader::UpdatePolicy,
+ this,
+ callback,
+ new_policy));
}
-void AsynchronousPolicyLoader::UpdatePolicy(DictionaryValue* new_policy_raw) {
- scoped_ptr<DictionaryValue> new_policy(new_policy_raw);
- DCHECK(policy_.get());
- policy_.swap(new_policy);
+void AsynchronousPolicyLoader::UpdatePolicy(const base::Closure& callback,
+ DictionaryValue* new_policy) {
+ policy_.reset(new_policy);
if (!stopped_)
- updates_callback_.Run();
+ callback.Run();
}
void AsynchronousPolicyLoader::InitAfterFileThreadAvailable() {

Powered by Google App Engine
This is Rietveld 408576698