Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / test / integration / fake_server_invalidation_service.h
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/signin/fake_profile_oauth2_token_service.h"
13 #include "components/invalidation/invalidation_service.h"
14 #include "components/invalidation/invalidator_registrar.h"
15 #include "google_apis/gaia/fake_identity_provider.h"
16 #include "sync/internal_api/public/base/model_type.h"
17 #include "sync/test/fake_server/fake_server.h"
18
19 namespace invalidation {
20 class InvalidationLogger;
21 }
22
23 namespace fake_server {
24
25 // An InvalidationService that is used in conjunction with FakeServer.
26 class FakeServerInvalidationService : public invalidation::InvalidationService,
27                                       public FakeServer::Observer {
28  public:
29   FakeServerInvalidationService();
30   ~FakeServerInvalidationService() override;
31
32   void RegisterInvalidationHandler(
33       syncer::InvalidationHandler* handler) override;
34   void UpdateRegisteredInvalidationIds(syncer::InvalidationHandler* handler,
35                                        const syncer::ObjectIdSet& ids) override;
36   void UnregisterInvalidationHandler(
37       syncer::InvalidationHandler* handler) override;
38
39   syncer::InvalidatorState GetInvalidatorState() const override;
40   std::string GetInvalidatorClientId() const override;
41   invalidation::InvalidationLogger* GetInvalidationLogger() override;
42   void RequestDetailedStatus(
43       base::Callback<void(const base::DictionaryValue&)> caller) const override;
44   IdentityProvider* GetIdentityProvider() override;
45
46   // Functions to enable or disable sending of self-notifications.  In the real
47   // world, clients do not receive notifications of their own commits.
48   void EnableSelfNotifications();
49   void DisableSelfNotifications();
50
51   // FakeServer::Observer:
52   void OnCommit(const std::string& committer_id,
53                 syncer::ModelTypeSet committed_model_types) override;
54
55  private:
56   std::string client_id_;
57   bool self_notify_;
58
59   syncer::InvalidatorRegistrar invalidator_registrar_;
60   FakeProfileOAuth2TokenService token_service_;
61   FakeIdentityProvider identity_provider_;
62
63   DISALLOW_COPY_AND_ASSIGN(FakeServerInvalidationService);
64 };
65
66 }  // namespace fake_server
67
68 #endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SERVICE_H_