[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / invalidation / fake_invalidation_service.h
blob9641c1f3aca3aeaabe61a29d5a680fa44c5941b8
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_
6 #define CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_
8 #include <list>
9 #include <utility>
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
14 #include "components/invalidation/invalidation_service.h"
15 #include "google_apis/gaia/fake_identity_provider.h"
16 #include "sync/notifier/invalidator_registrar.h"
17 #include "sync/notifier/mock_ack_handler.h"
19 namespace content {
20 class BrowserContext;
23 namespace syncer {
24 class Invalidation;
27 namespace invalidation {
29 class InvalidationLogger;
31 // An InvalidationService that emits invalidations only when
32 // its EmitInvalidationForTest method is called.
33 class FakeInvalidationService : public InvalidationService {
34 public:
35 FakeInvalidationService();
36 virtual ~FakeInvalidationService();
38 static KeyedService* Build(content::BrowserContext* context);
40 virtual void RegisterInvalidationHandler(
41 syncer::InvalidationHandler* handler) OVERRIDE;
42 virtual void UpdateRegisteredInvalidationIds(
43 syncer::InvalidationHandler* handler,
44 const syncer::ObjectIdSet& ids) OVERRIDE;
45 virtual void UnregisterInvalidationHandler(
46 syncer::InvalidationHandler* handler) OVERRIDE;
48 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE;
49 virtual std::string GetInvalidatorClientId() const OVERRIDE;
50 virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE;
51 virtual void RequestDetailedStatus(
52 base::Callback<void(const base::DictionaryValue&)> caller) const OVERRIDE;
53 virtual IdentityProvider* GetIdentityProvider() OVERRIDE;
55 void SetInvalidatorState(syncer::InvalidatorState state);
57 const syncer::InvalidatorRegistrar& invalidator_registrar() const {
58 return invalidator_registrar_;
61 void EmitInvalidationForTest(const syncer::Invalidation& invalidation);
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();
67 private:
68 std::string client_id_;
69 syncer::InvalidatorRegistrar invalidator_registrar_;
70 syncer::MockAckHandler mock_ack_handler_;
71 FakeProfileOAuth2TokenService token_service_;
72 FakeIdentityProvider identity_provider_;
74 DISALLOW_COPY_AND_ASSIGN(FakeInvalidationService);
77 } // namespace invalidation
79 #endif // CHROME_BROWSER_INVALIDATION_FAKE_INVALIDATION_SERVICE_H_