This source file includes following definitions.
- GetTokenService
- GetAccountId
- ShowLoginUI
- Build
- RegisterInvalidationHandler
- UpdateRegisteredInvalidationIds
- UnregisterInvalidationHandler
- GetInvalidatorState
- GetInvalidatorClientId
- GetInvalidationLogger
- RequestDetailedStatus
- GetInvalidationAuthProvider
- SetInvalidatorState
- EmitInvalidationForTest
- GetMockAckHandler
#include "chrome/browser/invalidation/fake_invalidation_service.h"
#include "base/macros.h"
#include "chrome/browser/invalidation/invalidation_service_util.h"
#include "sync/notifier/object_id_invalidation_map.h"
namespace invalidation {
FakeInvalidationAuthProvider::FakeInvalidationAuthProvider() {
token_service_.set_auto_post_fetch_response_on_message_loop(true);
}
FakeInvalidationAuthProvider::~FakeInvalidationAuthProvider() {}
OAuth2TokenService* FakeInvalidationAuthProvider::GetTokenService() {
return &token_service_;
}
std::string FakeInvalidationAuthProvider::GetAccountId() {
return "fake@example.com";
}
bool FakeInvalidationAuthProvider::ShowLoginUI() { return false; }
FakeInvalidationService::FakeInvalidationService()
: client_id_(GenerateInvalidatorClientId()) {
invalidator_registrar_.UpdateInvalidatorState(syncer::INVALIDATIONS_ENABLED);
}
FakeInvalidationService::~FakeInvalidationService() {
}
KeyedService* FakeInvalidationService::Build(content::BrowserContext* context) {
return new FakeInvalidationService();
}
void FakeInvalidationService::RegisterInvalidationHandler(
syncer::InvalidationHandler* handler) {
invalidator_registrar_.RegisterHandler(handler);
}
void FakeInvalidationService::UpdateRegisteredInvalidationIds(
syncer::InvalidationHandler* handler,
const syncer::ObjectIdSet& ids) {
invalidator_registrar_.UpdateRegisteredIds(handler, ids);
}
void FakeInvalidationService::UnregisterInvalidationHandler(
syncer::InvalidationHandler* handler) {
invalidator_registrar_.UnregisterHandler(handler);
}
syncer::InvalidatorState FakeInvalidationService::GetInvalidatorState() const {
return invalidator_registrar_.GetInvalidatorState();
}
std::string FakeInvalidationService::GetInvalidatorClientId() const {
return client_id_;
}
InvalidationLogger* FakeInvalidationService::GetInvalidationLogger() {
return NULL;
}
void FakeInvalidationService::RequestDetailedStatus(
base::Callback<void(const base::DictionaryValue&)> caller) const {
base::DictionaryValue value;
caller.Run(value);
}
InvalidationAuthProvider*
FakeInvalidationService::GetInvalidationAuthProvider() {
return &auth_provider_;
}
void FakeInvalidationService::SetInvalidatorState(
syncer::InvalidatorState state) {
invalidator_registrar_.UpdateInvalidatorState(state);
}
void FakeInvalidationService::EmitInvalidationForTest(
const syncer::Invalidation& invalidation) {
syncer::Invalidation invalidation_copy(invalidation);
syncer::ObjectIdSet registered_ids =
invalidator_registrar_.GetAllRegisteredIds();
if (registered_ids.find(invalidation.object_id()) == registered_ids.end()) {
mock_ack_handler_.RegisterUnsentInvalidation(&invalidation_copy);
return;
}
mock_ack_handler_.RegisterInvalidation(&invalidation_copy);
syncer::ObjectIdInvalidationMap invalidation_map;
invalidation_map.Insert(invalidation_copy);
invalidator_registrar_.DispatchInvalidationsToHandlers(invalidation_map);
}
syncer::MockAckHandler* FakeInvalidationService::GetMockAckHandler() {
return &mock_ack_handler_;
}
}