fake_server_invalidation_service.h revision 010d83a9304c5a91596085d917d248abff47903a
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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SERVICE_H_
6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SERVICE_H_
7
8#include <string>
9#include <utility>
10
11#include "base/basictypes.h"
12#include "chrome/browser/invalidation/invalidation_service.h"
13#include "chrome/browser/signin/fake_profile_oauth2_token_service.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"
17#include "sync/test/fake_server/fake_server.h"
18
19namespace content {
20class BrowserContext;
21}
22
23namespace invalidation {
24class InvalidationLogger;
25}
26
27namespace fake_server {
28
29// An InvalidationService that is used in conjunction with FakeServer.
30class FakeServerInvalidationService : public invalidation::InvalidationService,
31                                      public FakeServer::Observer {
32 public:
33  FakeServerInvalidationService();
34  virtual ~FakeServerInvalidationService();
35
36  static KeyedService* Build(content::BrowserContext* context);
37
38  virtual void RegisterInvalidationHandler(
39      syncer::InvalidationHandler* handler) OVERRIDE;
40  virtual void UpdateRegisteredInvalidationIds(
41      syncer::InvalidationHandler* handler,
42      const syncer::ObjectIdSet& ids) OVERRIDE;
43  virtual void UnregisterInvalidationHandler(
44      syncer::InvalidationHandler* handler) OVERRIDE;
45
46  virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE;
47  virtual std::string GetInvalidatorClientId() const OVERRIDE;
48  virtual invalidation::InvalidationLogger* GetInvalidationLogger() OVERRIDE;
49  virtual void RequestDetailedStatus(
50      base::Callback<void(const base::DictionaryValue&)> caller) const OVERRIDE;
51  virtual IdentityProvider* GetIdentityProvider() OVERRIDE;
52
53  // FakeServer::Observer:
54  virtual void OnCommit(syncer::ModelTypeSet committed_model_types) OVERRIDE;
55
56 private:
57  std::string client_id_;
58  syncer::InvalidatorRegistrar invalidator_registrar_;
59  FakeProfileOAuth2TokenService token_service_;
60  FakeIdentityProvider identity_provider_;
61
62  DISALLOW_COPY_AND_ASSIGN(FakeServerInvalidationService);
63};
64
65}  // namespace fake_server
66
67#endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SERVICE_H_
68