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 19namespace invalidation { 20class InvalidationLogger; 21} 22 23namespace fake_server { 24 25// An InvalidationService that is used in conjunction with FakeServer. 26class FakeServerInvalidationService : public invalidation::InvalidationService, 27 public FakeServer::Observer { 28 public: 29 FakeServerInvalidationService(); 30 virtual ~FakeServerInvalidationService(); 31 32 virtual void RegisterInvalidationHandler( 33 syncer::InvalidationHandler* handler) OVERRIDE; 34 virtual void UpdateRegisteredInvalidationIds( 35 syncer::InvalidationHandler* handler, 36 const syncer::ObjectIdSet& ids) OVERRIDE; 37 virtual void UnregisterInvalidationHandler( 38 syncer::InvalidationHandler* handler) OVERRIDE; 39 40 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; 41 virtual std::string GetInvalidatorClientId() const OVERRIDE; 42 virtual invalidation::InvalidationLogger* GetInvalidationLogger() OVERRIDE; 43 virtual void RequestDetailedStatus( 44 base::Callback<void(const base::DictionaryValue&)> caller) const OVERRIDE; 45 virtual IdentityProvider* GetIdentityProvider() OVERRIDE; 46 47 // Functions to enable or disable sending of self-notifications. In the real 48 // world, clients do not receive notifications of their own commits. 49 void EnableSelfNotifications(); 50 void DisableSelfNotifications(); 51 52 // FakeServer::Observer: 53 virtual void OnCommit( 54 const std::string& committer_id, 55 syncer::ModelTypeSet committed_model_types) OVERRIDE; 56 57 private: 58 std::string client_id_; 59 bool self_notify_; 60 61 syncer::InvalidatorRegistrar invalidator_registrar_; 62 FakeProfileOAuth2TokenService token_service_; 63 FakeIdentityProvider identity_provider_; 64 65 DISALLOW_COPY_AND_ASSIGN(FakeServerInvalidationService); 66}; 67 68} // namespace fake_server 69 70#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_FAKE_SERVER_INVALIDATION_SERVICE_H_ 71