1 // Copyright (c) 2013 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 "sync/sessions/nudge_tracker.h"
6 #include "sync/protocol/sync.pb.h"
11 NudgeTracker::NudgeTracker() { }
13 NudgeTracker::~NudgeTracker() { }
15 void NudgeTracker::CoalesceSources(const SyncSourceInfo
& source
) {
16 CoalesceStates(source
.types
, &source_info_
.types
);
17 source_info_
.updates_source
= source
.updates_source
;
20 bool NudgeTracker::IsEmpty() {
21 return source_info_
.types
.empty();
24 void NudgeTracker::Reset() {
25 source_info_
= SyncSourceInfo();
28 // TODO(rlarocque): This function often reports incorrect results. However, it
29 // is compatible with the "classic" behaviour. We would need to make the nudge
30 // tracker stop overwriting its own information (ie. fix crbug.com/231693)
31 // before we could even try to report correct results. The main issue is that
32 // an notifications and local modifications nudges may overlap with each other
33 // in sych a way that we lose track of which types were or were not locally
35 ModelTypeSet
NudgeTracker::GetLocallyModifiedTypes() const {
36 ModelTypeSet locally_modified
;
38 if (source_info_
.updates_source
!= sync_pb::GetUpdatesCallerInfo::LOCAL
) {
39 return locally_modified
;
42 for (ModelTypeInvalidationMap::const_iterator i
= source_info_
.types
.begin();
43 i
!= source_info().types
.end(); ++i
) {
44 locally_modified
.Put(i
->first
);
46 return locally_modified
;
49 } // namespace sessions