OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "sync/sessions/nudge_tracker.h" |
| 6 #include "sync/protocol/sync.pb.h" |
| 7 |
| 8 namespace syncer { |
| 9 namespace sessions { |
| 10 |
| 11 NudgeTracker::NudgeTracker() { } |
| 12 |
| 13 NudgeTracker::~NudgeTracker() { } |
| 14 |
| 15 void NudgeTracker::CoalesceSources(const SyncSourceInfo& source) { |
| 16 CoalesceStates(source.types, &source_info_.types); |
| 17 source_info_.updates_source = source.updates_source; |
| 18 } |
| 19 |
| 20 bool NudgeTracker::IsEmpty() { |
| 21 return source_info_.types.empty(); |
| 22 } |
| 23 |
| 24 void NudgeTracker::Reset() { |
| 25 source_info_ = SyncSourceInfo(); |
| 26 } |
| 27 |
| 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 |
| 34 // modified. |
| 35 ModelTypeSet NudgeTracker::GetLocallyModifiedTypes() const { |
| 36 ModelTypeSet locally_modified; |
| 37 |
| 38 if (source_info_.updates_source != sync_pb::GetUpdatesCallerInfo::LOCAL) { |
| 39 return locally_modified; |
| 40 } |
| 41 |
| 42 for (ModelTypeInvalidationMap::const_iterator i = source_info_.types.begin(); |
| 43 i != source_info().types.end(); ++i) { |
| 44 locally_modified.Put(i->first); |
| 45 } |
| 46 return locally_modified; |
| 47 } |
| 48 |
| 49 } // namespace sessions |
| 50 } // namespace syncer |
OLD | NEW |