Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ |
| 6 #define CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ | 6 #define CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ |
| 7 | 7 |
| 8 #include <list> | |
| 9 | |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "chrome/browser/invalidation/invalidation_service.h" | 11 #include "chrome/browser/invalidation/invalidation_service.h" |
| 10 #include "sync/notifier/invalidator_registrar.h" | 12 #include "sync/notifier/invalidator_registrar.h" |
| 11 | 13 |
| 12 namespace invalidation { | 14 namespace invalidation { |
| 13 | 15 |
| 14 // An InvalidationService that emits invalidations only when | 16 // An InvalidationService that emits invalidations only when |
| 15 // its EmitInvalidationForTest method is called. | 17 // its EmitInvalidationForTest method is called. |
| 16 class FakeInvalidationService : public InvalidationService { | 18 class FakeInvalidationService : public InvalidationService { |
| 17 public: | 19 public: |
| 18 FakeInvalidationService(); | 20 FakeInvalidationService(); |
| 19 virtual ~FakeInvalidationService(); | 21 virtual ~FakeInvalidationService(); |
| 20 | 22 |
| 21 virtual void RegisterInvalidationHandler( | 23 virtual void RegisterInvalidationHandler( |
| 22 syncer::InvalidationHandler* handler) OVERRIDE; | 24 syncer::InvalidationHandler* handler) OVERRIDE; |
| 23 virtual void UpdateRegisteredInvalidationIds( | 25 virtual void UpdateRegisteredInvalidationIds( |
| 24 syncer::InvalidationHandler* handler, | 26 syncer::InvalidationHandler* handler, |
| 25 const syncer::ObjectIdSet& ids) OVERRIDE; | 27 const syncer::ObjectIdSet& ids) OVERRIDE; |
| 26 virtual void UnregisterInvalidationHandler( | 28 virtual void UnregisterInvalidationHandler( |
| 27 syncer::InvalidationHandler* handler) OVERRIDE; | 29 syncer::InvalidationHandler* handler) OVERRIDE; |
| 28 | 30 |
| 29 virtual void AcknowledgeInvalidation( | 31 virtual void AcknowledgeInvalidation( |
| 30 const invalidation::ObjectId& id, | 32 const invalidation::ObjectId& id, |
| 31 const syncer::AckHandle& ack_handle) OVERRIDE; | 33 const syncer::AckHandle& ack_handle) OVERRIDE; |
| 32 | 34 |
| 33 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; | 35 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; |
| 34 virtual std::string GetInvalidatorClientId() const OVERRIDE; | 36 virtual std::string GetInvalidatorClientId() const OVERRIDE; |
| 35 | 37 |
| 36 void EmitInvalidationForTest( | 38 const syncer::InvalidatorRegistrar& invalidator_registrar() const { |
| 39 return invalidator_registrar_; | |
| 40 } | |
| 41 syncer::AckHandle EmitInvalidationForTest( | |
| 37 const invalidation::ObjectId& object_id, | 42 const invalidation::ObjectId& object_id, |
| 38 int64 version, | 43 int64 version, |
| 39 const std::string& payload); | 44 const std::string& payload); |
| 40 | 45 |
| 46 // Determines if the given AckHandle has been acknowledged. | |
| 47 bool IsInvalidationAcknowledged(const syncer::AckHandle& ack_handle) const; | |
| 48 | |
| 49 // Determines if AcknowledgeInvalidation was ever called with an invalid | |
| 50 // ObjectId/AckHandle pair. | |
| 51 bool ReceivedInvalidAcknowledgement() { | |
| 52 return received_invalid_acknowledgement_; | |
| 53 } | |
| 54 | |
| 41 private: | 55 private: |
| 42 std::string client_id_; | 56 std::string client_id_; |
| 43 syncer::InvalidatorRegistrar invalidator_registrar_; | 57 syncer::InvalidatorRegistrar invalidator_registrar_; |
| 58 typedef std::list<std::pair<syncer::AckHandle, invalidation::ObjectId> > | |
|
Joao da Silva
2013/07/23 20:44:47
We tend to prefer vector to list, but I leave that
Steve Condie
2013/07/24 01:42:04
I like list in this case for fast deletion in Ackn
rlarocque
2013/07/24 16:40:44
This is test code, so I don't care much about algo
| |
| 59 AckHandleList; | |
| 60 AckHandleList unacknowledged_handles_; | |
| 61 AckHandleList acknowledged_handles_; | |
| 62 bool received_invalid_acknowledgement_; | |
| 44 | 63 |
| 45 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationService); | 64 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationService); |
| 46 }; | 65 }; |
| 47 | 66 |
| 48 } // namespace invalidation | 67 } // namespace invalidation |
| 49 | 68 |
| 50 #endif // CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ | 69 #endif // CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ |
| OLD | NEW |