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

Unified Diff: chrome/browser/policy/cloud/cloud_policy_manager.cc

Issue 19733003: Implement cloud policy invalidations using the invalidation service framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 months 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/cloud/cloud_policy_manager.cc
diff --git a/chrome/browser/policy/cloud/cloud_policy_manager.cc b/chrome/browser/policy/cloud/cloud_policy_manager.cc
index 59fcc735805e8d8c7089a4d35663cc23ac49dbb8..4c704ba0cb741f0c5a81e7cb95e641a9eaa3f993 100644
--- a/chrome/browser/policy/cloud/cloud_policy_manager.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_manager.cc
@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/prefs/pref_service.h"
+#include "chrome/browser/policy/cloud/cloud_policy_refresh_scheduler.h"
#include "chrome/browser/policy/cloud/cloud_policy_service.h"
#include "chrome/browser/policy/policy_bundle.h"
#include "chrome/browser/policy/policy_map.h"
@@ -30,6 +31,19 @@ CloudPolicyManager::CloudPolicyManager(const PolicyNamespaceKey& policy_ns_key,
CloudPolicyManager::~CloudPolicyManager() {}
+void CloudPolicyManager::EnableInvalidations(
+ const base::Closure& initialize_invalidator) {
+ DCHECK(!initialize_invalidator.is_null());
+ DCHECK(initialize_invalidator_.is_null());
+ // If the refresh scheduler is already running, initialize the invalidator
+ // right away. Otherwise, store the closure so it can be invoked when the
+ // refresh scheduler starts.
+ if (core()->refresh_scheduler())
+ initialize_invalidator.Run();
+ else
+ initialize_invalidator_ = initialize_invalidator;
+}
+
void CloudPolicyManager::Shutdown() {
core_.Disconnect();
store()->RemoveObserver(this);
@@ -66,6 +80,24 @@ void CloudPolicyManager::OnStoreError(CloudPolicyStore* cloud_policy_store) {
CheckAndPublishPolicy();
}
+void CloudPolicyManager::SetInvalidationInfo(
+ int64 version,
+ const std::string& payload) {
+ DCHECK(core()->client());
Mattias Nissler (ping if slow) 2013/08/28 14:20:40 This DCHECK is optimistic, in fact there are crash
+ core()->client()->SetInvalidationInfo(version, payload);
+}
+
+void CloudPolicyManager::InvalidatePolicy() {
+ DCHECK(core()->refresh_scheduler());
Mattias Nissler (ping if slow) 2013/08/28 14:20:40 Same here.
+ core()->refresh_scheduler()->RefreshSoon();
+}
+
+void CloudPolicyManager::OnInvalidatorStateChanged(bool invalidations_enabled) {
+ DCHECK(core()->refresh_scheduler());
Mattias Nissler (ping if slow) 2013/08/28 14:20:40 and here.
+ core()->refresh_scheduler()->SetInvalidationServiceAvailability(
+ invalidations_enabled);
+}
+
void CloudPolicyManager::CheckAndPublishPolicy() {
if (IsInitializationComplete(POLICY_DOMAIN_CHROME) &&
!waiting_for_policy_refresh_) {
@@ -73,6 +105,14 @@ void CloudPolicyManager::CheckAndPublishPolicy() {
}
}
+void CloudPolicyManager::StartRefreshScheduler() {
+ DCHECK(!core()->refresh_scheduler());
+ core()->StartRefreshScheduler();
+ // Initialize the invalidator if EnableInvalidations has been called.
+ if (!initialize_invalidator_.is_null())
+ initialize_invalidator_.Run();
+}
+
scoped_ptr<PolicyBundle> CloudPolicyManager::CreatePolicyBundle() {
scoped_ptr<PolicyBundle> bundle(new PolicyBundle);
bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))

Powered by Google App Engine
This is Rietveld 408576698