OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/invalidation/fake_invalidation_service.h" | 5 #include "chrome/browser/invalidation/fake_invalidation_service.h" |
6 | 6 |
7 #include "chrome/browser/invalidation/invalidation_service_util.h" | 7 #include "chrome/browser/invalidation/invalidation_service_util.h" |
8 | 8 |
9 namespace invalidation { | 9 namespace invalidation { |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 std::string FakeInvalidationService::GetInvalidatorClientId() const { | 59 std::string FakeInvalidationService::GetInvalidatorClientId() const { |
60 return client_id_; | 60 return client_id_; |
61 } | 61 } |
62 | 62 |
63 void FakeInvalidationService::SetInvalidatorState( | 63 void FakeInvalidationService::SetInvalidatorState( |
64 syncer::InvalidatorState state) { | 64 syncer::InvalidatorState state) { |
65 invalidator_registrar_.UpdateInvalidatorState(state); | 65 invalidator_registrar_.UpdateInvalidatorState(state); |
66 } | 66 } |
67 | 67 |
68 syncer::AckHandle FakeInvalidationService::EmitInvalidationForTest( | 68 void FakeInvalidationService::EmitInvalidationForTest( |
69 const invalidation::ObjectId& object_id, | 69 const syncer::Invalidation& invalidation) { |
70 int64 version, | |
71 const std::string& payload) { | |
72 syncer::ObjectIdInvalidationMap invalidation_map; | 70 syncer::ObjectIdInvalidationMap invalidation_map; |
73 | 71 |
74 syncer::Invalidation inv; | 72 invalidation_map.Insert(invalidation); |
75 inv.version = version; | |
76 inv.payload = payload; | |
77 inv.ack_handle = syncer::AckHandle::CreateUnique(); | |
78 | |
79 invalidation_map.insert(std::make_pair(object_id, inv)); | |
80 unacknowledged_handles_.push_back( | 73 unacknowledged_handles_.push_back( |
81 AckHandleList::value_type(inv.ack_handle, object_id)); | 74 AckHandleList::value_type( |
| 75 invalidation.ack_handle(), |
| 76 invalidation.object_id())); |
82 | 77 |
83 invalidator_registrar_.DispatchInvalidationsToHandlers(invalidation_map); | 78 invalidator_registrar_.DispatchInvalidationsToHandlers(invalidation_map); |
84 | |
85 return inv.ack_handle; | |
86 } | 79 } |
87 | 80 |
88 bool FakeInvalidationService::IsInvalidationAcknowledged( | 81 bool FakeInvalidationService::IsInvalidationAcknowledged( |
89 const syncer::AckHandle& ack_handle) const { | 82 const syncer::AckHandle& ack_handle) const { |
90 // Try to find the given handle in the acknowledged list. | 83 // Try to find the given handle in the acknowledged list. |
91 AckHandleList::const_iterator begin = acknowledged_handles_.begin(); | 84 AckHandleList::const_iterator begin = acknowledged_handles_.begin(); |
92 AckHandleList::const_iterator end = acknowledged_handles_.end(); | 85 AckHandleList::const_iterator end = acknowledged_handles_.end(); |
93 for (AckHandleList::const_iterator handle = begin; handle != end; ++handle) | 86 for (AckHandleList::const_iterator handle = begin; handle != end; ++handle) |
94 if (handle->first.Equals(ack_handle)) | 87 if (handle->first.Equals(ack_handle)) |
95 return true; | 88 return true; |
96 return false; | 89 return false; |
97 } | 90 } |
98 | 91 |
99 } // namespace invalidation | 92 } // namespace invalidation |
OLD | NEW |