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

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

Issue 460573005: Pass highest handled invalidation version between invalidators (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nits. Created 6 years, 4 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_invalidator.cc
diff --git a/chrome/browser/policy/cloud/cloud_policy_invalidator.cc b/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
index ee83bbec10818a9ff1394a64093f5545bc254fa5..83996aae74ae795f26ef5cb800ea249528961fe6 100644
--- a/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
@@ -34,7 +34,8 @@ CloudPolicyInvalidator::CloudPolicyInvalidator(
enterprise_management::DeviceRegisterRequest::Type type,
CloudPolicyCore* core,
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
- scoped_ptr<base::Clock> clock)
+ scoped_ptr<base::Clock> clock,
+ int64 highest_handled_invalidation_version)
: state_(UNINITIALIZED),
type_(type),
core_(core),
@@ -47,11 +48,23 @@ CloudPolicyInvalidator::CloudPolicyInvalidator(
invalid_(false),
invalidation_version_(0),
unknown_version_invalidation_count_(0),
+ highest_handled_invalidation_version_(
+ highest_handled_invalidation_version),
weak_factory_(this),
max_fetch_delay_(kMaxFetchDelayDefault),
policy_hash_value_(0) {
DCHECK(core);
DCHECK(task_runner.get());
+ // |highest_handled_invalidation_version_| indicates the highest actual
+ // invalidation version handled. Since actual invalidations can have only
+ // positive versions, this member may be zero (no versioned invalidation
+ // handled yet) or positive. Negative values are not allowed:
+ //
+ // Negative version numbers are used internally by CloudPolicyInvalidator to
+ // keep track of unversioned invalidations. When such an invalidation is
+ // handled, |highest_handled_invalidation_version_| remains unchanged and does
+ // not become negative.
+ DCHECK_LE(0, highest_handled_invalidation_version_);
}
CloudPolicyInvalidator::~CloudPolicyInvalidator() {
@@ -154,10 +167,16 @@ void CloudPolicyInvalidator::OnStoreLoaded(CloudPolicyStore* store) {
METRIC_POLICY_REFRESH_SIZE);
}
+ const int64 store_invalidation_version = store->invalidation_version();
+
// If the policy was invalid and the version stored matches the latest
// invalidation version, acknowledge the latest invalidation.
- if (invalid_ && store->invalidation_version() == invalidation_version_)
+ if (invalid_ && store_invalidation_version == invalidation_version_)
AcknowledgeInvalidation();
+
+ // Update the highest invalidation version that was handled already.
+ if (store_invalidation_version > highest_handled_invalidation_version_)
+ highest_handled_invalidation_version_ = store_invalidation_version;
}
UpdateRegistration(store->policy());
@@ -175,6 +194,14 @@ void CloudPolicyInvalidator::HandleInvalidation(
return;
}
+ if (!invalidation.is_unknown_version() &&
+ invalidation.version() <= highest_handled_invalidation_version_) {
+ // If this invalidation version was handled already, acknowledge the
+ // invalidation but ignore it otherwise.
+ invalidation.Acknowledge();
+ return;
+ }
+
// If there is still a pending invalidation, acknowledge it, since we only
// care about the latest invalidation.
if (invalid_)

Powered by Google App Engine
This is Rietveld 408576698