Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: chrome/browser/sync/test/integration/fake_server_invalidation_service.cc

Issue 296743005: sync: Implement fake server reflection blocking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split enable and disable methods Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/test/integration/fake_server_invalidation_service. h" 5 #include "chrome/browser/sync/test/integration/fake_server_invalidation_service. h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "components/invalidation/invalidation_service_util.h" 10 #include "components/invalidation/invalidation_service_util.h"
11 #include "sync/internal_api/public/base/invalidation.h" 11 #include "sync/internal_api/public/base/invalidation.h"
12 #include "sync/internal_api/public/base/model_type.h" 12 #include "sync/internal_api/public/base/model_type.h"
13 #include "sync/notifier/object_id_invalidation_map.h" 13 #include "sync/notifier/object_id_invalidation_map.h"
14 # 14 #
15 15
16 namespace fake_server { 16 namespace fake_server {
17 17
18 FakeServerInvalidationService::FakeServerInvalidationService() 18 FakeServerInvalidationService::FakeServerInvalidationService()
19 : client_id_(invalidation::GenerateInvalidatorClientId()), 19 : client_id_(invalidation::GenerateInvalidatorClientId()),
20 self_notify_(true),
20 identity_provider_(&token_service_) { 21 identity_provider_(&token_service_) {
21 invalidator_registrar_.UpdateInvalidatorState(syncer::INVALIDATIONS_ENABLED); 22 invalidator_registrar_.UpdateInvalidatorState(syncer::INVALIDATIONS_ENABLED);
22 } 23 }
23 24
24 FakeServerInvalidationService::~FakeServerInvalidationService() { 25 FakeServerInvalidationService::~FakeServerInvalidationService() {
25 } 26 }
26 27
27 // static 28 // static
28 KeyedService* FakeServerInvalidationService::Build( 29 KeyedService* FakeServerInvalidationService::Build(
29 content::BrowserContext* context) { 30 content::BrowserContext* context) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void FakeServerInvalidationService::RequestDetailedStatus( 64 void FakeServerInvalidationService::RequestDetailedStatus(
64 base::Callback<void(const base::DictionaryValue&)> caller) const { 65 base::Callback<void(const base::DictionaryValue&)> caller) const {
65 base::DictionaryValue value; 66 base::DictionaryValue value;
66 caller.Run(value); 67 caller.Run(value);
67 } 68 }
68 69
69 IdentityProvider* FakeServerInvalidationService::GetIdentityProvider() { 70 IdentityProvider* FakeServerInvalidationService::GetIdentityProvider() {
70 return &identity_provider_; 71 return &identity_provider_;
71 } 72 }
72 73
74 void FakeServerInvalidationService::EnableSelfNotifications() {
75 self_notify_ = true;
76 }
77
78 void FakeServerInvalidationService::DisableSelfNotifications() {
79 self_notify_ = false;
80 }
81
73 void FakeServerInvalidationService::OnCommit( 82 void FakeServerInvalidationService::OnCommit(
83 const std::string& committer_id,
74 syncer::ModelTypeSet committed_model_types) { 84 syncer::ModelTypeSet committed_model_types) {
75 syncer::ObjectIdSet object_ids = syncer::ModelTypeSetToObjectIdSet( 85 syncer::ObjectIdSet object_ids = syncer::ModelTypeSetToObjectIdSet(
76 committed_model_types); 86 committed_model_types);
77 syncer::ObjectIdInvalidationMap invalidation_map; 87 syncer::ObjectIdInvalidationMap invalidation_map;
78 for (syncer::ObjectIdSet::const_iterator it = object_ids.begin(); 88 for (syncer::ObjectIdSet::const_iterator it = object_ids.begin();
79 it != object_ids.end(); ++it) { 89 it != object_ids.end(); ++it) {
80 // TODO(pvalenzuela): Create more refined invalidations instead of 90 // TODO(pvalenzuela): Create more refined invalidations instead of
81 // invalidating all items of a given type. 91 // invalidating all items of a given type.
82 invalidation_map.Insert(syncer::Invalidation::InitUnknownVersion(*it)); 92
93 if (self_notify_ || client_id_ != committer_id) {
94 invalidation_map.Insert(syncer::Invalidation::InitUnknownVersion(*it));
95 }
83 } 96 }
84 invalidator_registrar_.DispatchInvalidationsToHandlers(invalidation_map); 97 invalidator_registrar_.DispatchInvalidationsToHandlers(invalidation_map);
85 } 98 }
86 99
87 } // namespace fake_server 100 } // namespace fake_server
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698