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

Unified Diff: chrome/browser/invalidation/fake_invalidation_service.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/invalidation/fake_invalidation_service.cc
diff --git a/chrome/browser/invalidation/fake_invalidation_service.cc b/chrome/browser/invalidation/fake_invalidation_service.cc
index a19f4fb092b4b68777bd96cee070c8af6b61e2fb..018ad72d739e570e29cbfd19f248a2097a3c343a 100644
--- a/chrome/browser/invalidation/fake_invalidation_service.cc
+++ b/chrome/browser/invalidation/fake_invalidation_service.cc
@@ -34,7 +34,20 @@ void FakeInvalidationService::UnregisterInvalidationHandler(
void FakeInvalidationService::AcknowledgeInvalidation(
const invalidation::ObjectId& id,
const syncer::AckHandle& ack_handle) {
- // TODO(sync): Use assertions to ensure this function is invoked correctly.
+ // Try to find the given handle and object id in the unacknowledged list.
+ AckHandleList::iterator handle;
+ AckHandleList::iterator begin = unacknowledged_handles_.begin();
+ AckHandleList::iterator end = unacknowledged_handles_.end();
+ for (handle = begin; handle != end; handle++)
Joao da Silva 2013/07/23 20:44:47 ++handle
Steve Condie 2013/07/24 01:42:04 Done.
+ if (handle->first.Equals(ack_handle) && handle->second == id)
+ break;
+ if (handle == end)
+ received_invalid_acknowledgement_ = false;
+ else
+ unacknowledged_handles_.erase(handle);
+
+ // Add to the acknowledged list.
+ acknowledged_handles_.push_back(AckHandleList::value_type(ack_handle, id));
}
syncer::InvalidatorState FakeInvalidationService::GetInvalidatorState() const {
@@ -45,7 +58,7 @@ std::string FakeInvalidationService::GetInvalidatorClientId() const {
return client_id_;
}
-void FakeInvalidationService::EmitInvalidationForTest(
+syncer::AckHandle FakeInvalidationService::EmitInvalidationForTest(
const invalidation::ObjectId& object_id,
int64 version,
const std::string& payload) {
@@ -59,6 +72,21 @@ void FakeInvalidationService::EmitInvalidationForTest(
invalidation_map.insert(std::make_pair(object_id, inv));
invalidator_registrar_.DispatchInvalidationsToHandlers(invalidation_map);
+
+ unacknowledged_handles_.push_back(
+ AckHandleList::value_type(inv.ack_handle, object_id));
+ return inv.ack_handle;
+}
+
+bool FakeInvalidationService::IsInvalidationAcknowledged(
+ const syncer::AckHandle& ack_handle) const {
+ // Try to find the given handle in the acknowledged list.
+ AckHandleList::const_iterator begin = acknowledged_handles_.begin();
+ AckHandleList::const_iterator end = acknowledged_handles_.end();
+ for (AckHandleList::const_iterator handle = begin; handle != end; handle++)
Joao da Silva 2013/07/23 20:44:47 ++handle
Steve Condie 2013/07/24 01:42:04 Done.
+ if (handle->first.Equals(ack_handle))
+ return true;
+ return false;
}
} // namespace invalidation

Powered by Google App Engine
This is Rietveld 408576698