BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / fake_server_invalidation_service.cc
blob487500d467551c94c257e74afe523aa7413d9444
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.
5 #include "chrome/browser/sync/test/integration/fake_server_invalidation_service.h"
7 #include <string>
9 #include "base/macros.h"
10 #include "components/invalidation/impl/invalidation_service_util.h"
11 #include "components/invalidation/public/invalidation.h"
12 #include "components/invalidation/public/object_id_invalidation_map.h"
13 #include "components/sync_driver/invalidation_helper.h"
14 #include "sync/internal_api/public/base/model_type.h"
16 namespace fake_server {
18 FakeServerInvalidationService::FakeServerInvalidationService()
19 : client_id_(invalidation::GenerateInvalidatorClientId()),
20 self_notify_(true),
21 identity_provider_(&token_service_) {
22 invalidator_registrar_.UpdateInvalidatorState(syncer::INVALIDATIONS_ENABLED);
25 FakeServerInvalidationService::~FakeServerInvalidationService() {
28 void FakeServerInvalidationService::RegisterInvalidationHandler(
29 syncer::InvalidationHandler* handler) {
30 invalidator_registrar_.RegisterHandler(handler);
33 bool FakeServerInvalidationService::UpdateRegisteredInvalidationIds(
34 syncer::InvalidationHandler* handler,
35 const syncer::ObjectIdSet& ids) {
36 return invalidator_registrar_.UpdateRegisteredIds(handler, ids);
39 void FakeServerInvalidationService::UnregisterInvalidationHandler(
40 syncer::InvalidationHandler* handler) {
41 invalidator_registrar_.UnregisterHandler(handler);
44 syncer::InvalidatorState FakeServerInvalidationService::GetInvalidatorState()
45 const {
46 return invalidator_registrar_.GetInvalidatorState();
49 std::string FakeServerInvalidationService::GetInvalidatorClientId() const {
50 return client_id_;
53 invalidation::InvalidationLogger*
54 FakeServerInvalidationService::GetInvalidationLogger() {
55 return NULL;
58 void FakeServerInvalidationService::RequestDetailedStatus(
59 base::Callback<void(const base::DictionaryValue&)> caller) const {
60 base::DictionaryValue value;
61 caller.Run(value);
64 IdentityProvider* FakeServerInvalidationService::GetIdentityProvider() {
65 return &identity_provider_;
68 void FakeServerInvalidationService::EnableSelfNotifications() {
69 self_notify_ = true;
72 void FakeServerInvalidationService::DisableSelfNotifications() {
73 self_notify_ = false;
76 void FakeServerInvalidationService::OnCommit(
77 const std::string& committer_id,
78 syncer::ModelTypeSet committed_model_types) {
79 syncer::ObjectIdSet object_ids = syncer::ModelTypeSetToObjectIdSet(
80 committed_model_types);
81 syncer::ObjectIdInvalidationMap invalidation_map;
82 for (syncer::ObjectIdSet::const_iterator it = object_ids.begin();
83 it != object_ids.end(); ++it) {
84 // TODO(pvalenzuela): Create more refined invalidations instead of
85 // invalidating all items of a given type.
87 if (self_notify_ || client_id_ != committer_id) {
88 invalidation_map.Insert(syncer::Invalidation::InitUnknownVersion(*it));
91 invalidator_registrar_.DispatchInvalidationsToHandlers(invalidation_map);
94 } // namespace fake_server