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

Side by Side Diff: sync/sessions/nudge_tracker.cc

Issue 15764010: Experimental functionize patch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync: Expose sync functionality as functions Created 7 years, 6 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
« no previous file with comments | « sync/sessions/nudge_tracker.h ('k') | sync/sessions/nudge_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 "sync/sessions/nudge_tracker.h" 5 #include "sync/sessions/nudge_tracker.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "sync/internal_api/public/base/invalidation.h" 8 #include "sync/internal_api/public/base/invalidation.h"
9 #include "sync/internal_api/public/sessions/sync_source_info.h" 9 #include "sync/internal_api/public/sessions/sync_source_info.h"
10 #include "sync/protocol/sync.pb.h" 10 #include "sync/protocol/sync.pb.h"
(...skipping 10 matching lines...) Expand all
21 ModelTypeSet protocol_types = ProtocolTypes(); 21 ModelTypeSet protocol_types = ProtocolTypes();
22 // Default initialize all the type trackers. 22 // Default initialize all the type trackers.
23 for (ModelTypeSet::Iterator it = protocol_types.First(); it.Good(); 23 for (ModelTypeSet::Iterator it = protocol_types.First(); it.Good();
24 it.Inc()) { 24 it.Inc()) {
25 type_trackers_[it.Get()] = DataTypeTracker(); 25 type_trackers_[it.Get()] = DataTypeTracker();
26 } 26 }
27 } 27 }
28 28
29 NudgeTracker::~NudgeTracker() { } 29 NudgeTracker::~NudgeTracker() { }
30 30
31 bool NudgeTracker::IsSyncRequired() { 31 bool NudgeTracker::IsSyncRequired() const {
32 for (TypeTrackerMap::iterator it = type_trackers_.begin(); 32 for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
33 it != type_trackers_.end(); ++it) { 33 it != type_trackers_.end(); ++it) {
34 if (it->second.IsSyncRequired()) { 34 if (it->second.IsSyncRequired()) {
35 return true; 35 return true;
36 } 36 }
37 } 37 }
38 return false; 38 return false;
39 } 39 }
40 40
41 void NudgeTracker::RecordSuccessfulSyncCycle() { 41 void NudgeTracker::RecordSuccessfulSyncCycle() {
42 updates_source_ = sync_pb::GetUpdatesCallerInfo::UNKNOWN; 42 updates_source_ = sync_pb::GetUpdatesCallerInfo::UNKNOWN;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // any invalidations. 188 // any invalidations.
189 Invalidation invalidation; 189 Invalidation invalidation;
190 invalidation.payload = ""; 190 invalidation.payload = "";
191 invalidation_map.insert(std::make_pair(it->first, invalidation)); 191 invalidation_map.insert(std::make_pair(it->first, invalidation));
192 } 192 }
193 } 193 }
194 194
195 return SyncSourceInfo(updates_source_, invalidation_map); 195 return SyncSourceInfo(updates_source_, invalidation_map);
196 } 196 }
197 197
198 void NudgeTracker::SetLegacyNotificationHint(
199 ModelType type,
200 sync_pb::DataTypeProgressMarker* progress) const {
201 DCHECK(type_trackers_.find(type) != type_trackers_.end());
202 type_trackers_.find(type)->second.SetLegacyNotificationHint(progress);
203 }
204
198 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource NudgeTracker::updates_source() 205 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource NudgeTracker::updates_source()
199 const { 206 const {
200 return updates_source_; 207 return updates_source_;
201 } 208 }
202 209
203 void NudgeTracker::FillProtoMessage( 210 void NudgeTracker::FillProtoMessage(
204 ModelType type, 211 ModelType type,
205 sync_pb::GetUpdateTriggers* msg) const { 212 sync_pb::GetUpdateTriggers* msg) const {
206 DCHECK(type_trackers_.find(type) != type_trackers_.end()); 213 DCHECK(type_trackers_.find(type) != type_trackers_.end());
207 214
208 // Fill what we can from the global data. 215 // Fill what we can from the global data.
209 msg->set_invalidations_out_of_sync(invalidations_out_of_sync_); 216 msg->set_invalidations_out_of_sync(invalidations_out_of_sync_);
210 217
211 // Delegate the type-specific work to the DataTypeTracker class. 218 // Delegate the type-specific work to the DataTypeTracker class.
212 type_trackers_.find(type)->second.FillGetUpdatesTriggersMessage(msg); 219 type_trackers_.find(type)->second.FillGetUpdatesTriggersMessage(msg);
213 } 220 }
214 221
215 void NudgeTracker::SetHintBufferSize(size_t size) { 222 void NudgeTracker::SetHintBufferSize(size_t size) {
216 for (TypeTrackerMap::iterator it = type_trackers_.begin(); 223 for (TypeTrackerMap::iterator it = type_trackers_.begin();
217 it != type_trackers_.end(); ++it) { 224 it != type_trackers_.end(); ++it) {
218 it->second.UpdatePayloadBufferSize(size); 225 it->second.UpdatePayloadBufferSize(size);
219 } 226 }
220 } 227 }
221 228
222 } // namespace sessions 229 } // namespace sessions
223 } // namespace syncer 230 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/sessions/nudge_tracker.h ('k') | sync/sessions/nudge_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698