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

Unified Diff: chrome/browser/invalidation/fake_invalidation_service.cc

Issue 23754021: Invalidation trickles mega-patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 dcf5c2f05aeb3aa0194cbdce820ce4cc604abcd9..faf422576910f39ad68fd5ebe83cac0b16ff7f7a 100644
--- a/chrome/browser/invalidation/fake_invalidation_service.cc
+++ b/chrome/browser/invalidation/fake_invalidation_service.cc
@@ -5,12 +5,12 @@
#include "chrome/browser/invalidation/fake_invalidation_service.h"
#include "chrome/browser/invalidation/invalidation_service_util.h"
+#include "sync/notifier/object_id_invalidation_map.h"
namespace invalidation {
FakeInvalidationService::FakeInvalidationService()
- : client_id_(GenerateInvalidatorClientId()),
- received_invalid_acknowledgement_(false) {
+ : client_id_(GenerateInvalidatorClientId()) {
invalidator_registrar_.UpdateInvalidatorState(syncer::INVALIDATIONS_ENABLED);
}
@@ -33,25 +33,6 @@ void FakeInvalidationService::UnregisterInvalidationHandler(
invalidator_registrar_.UnregisterHandler(handler);
}
-void FakeInvalidationService::AcknowledgeInvalidation(
- const invalidation::ObjectId& id,
- const syncer::AckHandle& ack_handle) {
- // 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)
- 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 {
return invalidator_registrar_.GetInvalidatorState();
}
@@ -65,35 +46,30 @@ void FakeInvalidationService::SetInvalidatorState(
invalidator_registrar_.UpdateInvalidatorState(state);
}
-syncer::AckHandle FakeInvalidationService::EmitInvalidationForTest(
- const invalidation::ObjectId& object_id,
- int64 version,
- const std::string& payload) {
+void FakeInvalidationService::EmitInvalidationForTest(
+ const syncer::Invalidation& invalidation) {
+ // This function might need to modify the invalidator, so we start by making
+ // an identical copy of it.
+ syncer::Invalidation invalidation_copy(invalidation);
+
+ // If no one is listening to this invalidation, do not send it out.
+ syncer::ObjectIdSet registered_ids =
+ invalidator_registrar_.GetAllRegisteredIds();
+ if (registered_ids.find(invalidation.GetObjectId()) == registered_ids.end()) {
+ mock_ack_handler_.RegisterUnsentInvalidation(&invalidation_copy);
+ return;
+ }
+
+ // Otherwise, register the invalidation with the mock_ack_handler_ and deliver
+ // it to the appropriate consumer.
+ mock_ack_handler_.RegisterInvalidation(&invalidation_copy);
syncer::ObjectIdInvalidationMap invalidation_map;
-
- syncer::Invalidation inv;
- inv.version = version;
- inv.payload = payload;
- inv.ack_handle = syncer::AckHandle::CreateUnique();
-
- invalidation_map.insert(std::make_pair(object_id, inv));
- unacknowledged_handles_.push_back(
- AckHandleList::value_type(inv.ack_handle, object_id));
-
+ invalidation_map.Insert(invalidation_copy);
invalidator_registrar_.DispatchInvalidationsToHandlers(invalidation_map);
-
- 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)
- if (handle->first.Equals(ack_handle))
- return true;
- return false;
+syncer::MockAckHandler* FakeInvalidationService::GetMockAckHandler() {
+ return &mock_ack_handler_;
}
} // namespace invalidation
« no previous file with comments | « chrome/browser/invalidation/fake_invalidation_service.h ('k') | chrome/browser/invalidation/invalidation_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698