OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SERVICE_H_ |
6 #define CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SERVICE_H_ |
7 | 7 |
8 #include <list> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | |
13 #include "chrome/browser/invalidation/invalidation_service.h" | 12 #include "chrome/browser/invalidation/invalidation_service.h" |
14 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 13 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
15 #include "google_apis/gaia/fake_identity_provider.h" | 14 #include "google_apis/gaia/fake_identity_provider.h" |
| 15 #include "sync/internal_api/public/base/model_type.h" |
16 #include "sync/notifier/invalidator_registrar.h" | 16 #include "sync/notifier/invalidator_registrar.h" |
17 #include "sync/notifier/mock_ack_handler.h" | 17 #include "sync/test/fake_server/fake_server.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 class BrowserContext; | 20 class BrowserContext; |
21 } | 21 } |
22 | 22 |
23 namespace syncer { | 23 namespace invalidation { |
24 class Invalidation; | 24 class InvalidationLogger; |
25 } | 25 } |
26 | 26 |
27 namespace invalidation { | 27 namespace fake_server { |
28 | 28 |
29 class InvalidationLogger; | 29 // An InvalidationService that is used in conjunction with FakeServer. |
30 | 30 class FakeServerInvalidationService : public invalidation::InvalidationService, |
31 // An InvalidationService that emits invalidations only when | 31 public FakeServer::Observer { |
32 // its EmitInvalidationForTest method is called. | |
33 class FakeInvalidationService : public InvalidationService { | |
34 public: | 32 public: |
35 FakeInvalidationService(); | 33 FakeServerInvalidationService(); |
36 virtual ~FakeInvalidationService(); | 34 virtual ~FakeServerInvalidationService(); |
37 | 35 |
38 static KeyedService* Build(content::BrowserContext* context); | 36 static KeyedService* Build(content::BrowserContext* context); |
39 | 37 |
40 virtual void RegisterInvalidationHandler( | 38 virtual void RegisterInvalidationHandler( |
41 syncer::InvalidationHandler* handler) OVERRIDE; | 39 syncer::InvalidationHandler* handler) OVERRIDE; |
42 virtual void UpdateRegisteredInvalidationIds( | 40 virtual void UpdateRegisteredInvalidationIds( |
43 syncer::InvalidationHandler* handler, | 41 syncer::InvalidationHandler* handler, |
44 const syncer::ObjectIdSet& ids) OVERRIDE; | 42 const syncer::ObjectIdSet& ids) OVERRIDE; |
45 virtual void UnregisterInvalidationHandler( | 43 virtual void UnregisterInvalidationHandler( |
46 syncer::InvalidationHandler* handler) OVERRIDE; | 44 syncer::InvalidationHandler* handler) OVERRIDE; |
47 | 45 |
48 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; | 46 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; |
49 virtual std::string GetInvalidatorClientId() const OVERRIDE; | 47 virtual std::string GetInvalidatorClientId() const OVERRIDE; |
50 virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE; | 48 virtual invalidation::InvalidationLogger* GetInvalidationLogger() OVERRIDE; |
51 virtual void RequestDetailedStatus( | 49 virtual void RequestDetailedStatus( |
52 base::Callback<void(const base::DictionaryValue&)> caller) const OVERRIDE; | 50 base::Callback<void(const base::DictionaryValue&)> caller) const OVERRIDE; |
53 virtual IdentityProvider* GetIdentityProvider() OVERRIDE; | 51 virtual IdentityProvider* GetIdentityProvider() OVERRIDE; |
54 | 52 |
55 void SetInvalidatorState(syncer::InvalidatorState state); | 53 // FakeServer::Observer: |
56 | 54 virtual void OnCommit(syncer::ModelTypeSet committed_model_types) OVERRIDE; |
57 const syncer::InvalidatorRegistrar& invalidator_registrar() const { | |
58 return invalidator_registrar_; | |
59 } | |
60 | |
61 void EmitInvalidationForTest(const syncer::Invalidation& invalidation); | |
62 | |
63 // Emitted invalidations will be hooked up to this AckHandler. Clients can | |
64 // query it to assert the invalidaitons are being acked properly. | |
65 syncer::MockAckHandler* GetMockAckHandler(); | |
66 | 55 |
67 private: | 56 private: |
68 std::string client_id_; | 57 std::string client_id_; |
69 syncer::InvalidatorRegistrar invalidator_registrar_; | 58 syncer::InvalidatorRegistrar invalidator_registrar_; |
70 syncer::MockAckHandler mock_ack_handler_; | |
71 FakeProfileOAuth2TokenService token_service_; | 59 FakeProfileOAuth2TokenService token_service_; |
72 FakeIdentityProvider identity_provider_; | 60 FakeIdentityProvider identity_provider_; |
73 | 61 |
74 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationService); | 62 DISALLOW_COPY_AND_ASSIGN(FakeServerInvalidationService); |
75 }; | 63 }; |
76 | 64 |
77 } // namespace invalidation | 65 } // namespace fake_server |
78 | 66 |
79 #endif // CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_ | 67 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SERVICE
_H_ |
OLD | NEW |