| 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> | 8 #include <list> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "chrome/browser/invalidation/invalidation_auth_provider.h" |
| 12 #include "chrome/browser/invalidation/invalidation_service.h" | 13 #include "chrome/browser/invalidation/invalidation_service.h" |
| 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 13 #include "sync/notifier/invalidator_registrar.h" | 15 #include "sync/notifier/invalidator_registrar.h" |
| 14 #include "sync/notifier/mock_ack_handler.h" | 16 #include "sync/notifier/mock_ack_handler.h" |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| 17 class BrowserContext; | 19 class BrowserContext; |
| 18 } | 20 } |
| 19 | 21 |
| 20 namespace syncer { | 22 namespace syncer { |
| 21 class Invalidation; | 23 class Invalidation; |
| 22 } | 24 } |
| 23 | 25 |
| 24 namespace invalidation { | 26 namespace invalidation { |
| 25 | 27 |
| 26 class InvalidationLogger; | 28 class InvalidationLogger; |
| 27 | 29 |
| 30 // Fake invalidation auth provider implementation. |
| 31 class FakeInvalidationAuthProvider : public InvalidationAuthProvider { |
| 32 public: |
| 33 FakeInvalidationAuthProvider(); |
| 34 virtual ~FakeInvalidationAuthProvider(); |
| 35 |
| 36 // InvalidationAuthProvider: |
| 37 virtual OAuth2TokenService* GetTokenService() OVERRIDE; |
| 38 virtual std::string GetAccountId() OVERRIDE; |
| 39 virtual bool ShowLoginUI() OVERRIDE; |
| 40 |
| 41 private: |
| 42 FakeProfileOAuth2TokenService token_service_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationAuthProvider); |
| 45 }; |
| 46 |
| 28 // An InvalidationService that emits invalidations only when | 47 // An InvalidationService that emits invalidations only when |
| 29 // its EmitInvalidationForTest method is called. | 48 // its EmitInvalidationForTest method is called. |
| 30 class FakeInvalidationService : public InvalidationService { | 49 class FakeInvalidationService : public InvalidationService { |
| 31 public: | 50 public: |
| 32 FakeInvalidationService(); | 51 FakeInvalidationService(); |
| 33 virtual ~FakeInvalidationService(); | 52 virtual ~FakeInvalidationService(); |
| 34 | 53 |
| 35 static BrowserContextKeyedService* Build(content::BrowserContext* context); | 54 static BrowserContextKeyedService* Build(content::BrowserContext* context); |
| 36 | 55 |
| 37 virtual void RegisterInvalidationHandler( | 56 virtual void RegisterInvalidationHandler( |
| 38 syncer::InvalidationHandler* handler) OVERRIDE; | 57 syncer::InvalidationHandler* handler) OVERRIDE; |
| 39 virtual void UpdateRegisteredInvalidationIds( | 58 virtual void UpdateRegisteredInvalidationIds( |
| 40 syncer::InvalidationHandler* handler, | 59 syncer::InvalidationHandler* handler, |
| 41 const syncer::ObjectIdSet& ids) OVERRIDE; | 60 const syncer::ObjectIdSet& ids) OVERRIDE; |
| 42 virtual void UnregisterInvalidationHandler( | 61 virtual void UnregisterInvalidationHandler( |
| 43 syncer::InvalidationHandler* handler) OVERRIDE; | 62 syncer::InvalidationHandler* handler) OVERRIDE; |
| 44 | 63 |
| 45 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; | 64 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; |
| 46 virtual std::string GetInvalidatorClientId() const OVERRIDE; | 65 virtual std::string GetInvalidatorClientId() const OVERRIDE; |
| 47 virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE; | 66 virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE; |
| 67 virtual InvalidationAuthProvider* GetInvalidationAuthProvider() OVERRIDE; |
| 48 | 68 |
| 49 void SetInvalidatorState(syncer::InvalidatorState state); | 69 void SetInvalidatorState(syncer::InvalidatorState state); |
| 50 | 70 |
| 51 const syncer::InvalidatorRegistrar& invalidator_registrar() const { | 71 const syncer::InvalidatorRegistrar& invalidator_registrar() const { |
| 52 return invalidator_registrar_; | 72 return invalidator_registrar_; |
| 53 } | 73 } |
| 54 | 74 |
| 55 void EmitInvalidationForTest(const syncer::Invalidation& invalidation); | 75 void EmitInvalidationForTest(const syncer::Invalidation& invalidation); |
| 56 | 76 |
| 57 // Emitted invalidations will be hooked up to this AckHandler. Clients can | 77 // Emitted invalidations will be hooked up to this AckHandler. Clients can |
| 58 // query it to assert the invalidaitons are being acked properly. | 78 // query it to assert the invalidaitons are being acked properly. |
| 59 syncer::MockAckHandler* GetMockAckHandler(); | 79 syncer::MockAckHandler* GetMockAckHandler(); |
| 60 | 80 |
| 61 private: | 81 private: |
| 62 std::string client_id_; | 82 std::string client_id_; |
| 63 syncer::InvalidatorRegistrar invalidator_registrar_; | 83 syncer::InvalidatorRegistrar invalidator_registrar_; |
| 64 syncer::MockAckHandler mock_ack_handler_; | 84 syncer::MockAckHandler mock_ack_handler_; |
| 85 FakeInvalidationAuthProvider auth_provider_; |
| 65 | 86 |
| 66 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationService); | 87 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationService); |
| 67 }; | 88 }; |
| 68 | 89 |
| 69 } // namespace invalidation | 90 } // namespace invalidation |
| 70 | 91 |
| 71 #endif // CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ | 92 #endif // CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ |
| OLD | NEW |