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

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

Issue 124083002: Client-side changes to support retry GU. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 (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/notifier/invalidation_util.h" 9 #include "sync/notifier/invalidation_util.h"
10 #include "sync/notifier/object_id_invalidation_map.h" 10 #include "sync/notifier/object_id_invalidation_map.h"
11 #include "sync/protocol/sync.pb.h" 11 #include "sync/protocol/sync.pb.h"
12 12
13 namespace syncer { 13 namespace syncer {
14 namespace sessions { 14 namespace sessions {
15 15
16 size_t NudgeTracker::kDefaultMaxPayloadsPerType = 10; 16 size_t NudgeTracker::kDefaultMaxPayloadsPerType = 10;
17 17
18 NudgeTracker::NudgeTracker() 18 NudgeTracker::NudgeTracker(base::Clock* clock)
19 : updates_source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN), 19 : clock_(clock),
20 updates_source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN),
20 invalidations_enabled_(false), 21 invalidations_enabled_(false),
21 invalidations_out_of_sync_(true) { 22 invalidations_out_of_sync_(true) {
22 ModelTypeSet protocol_types = ProtocolTypes(); 23 ModelTypeSet protocol_types = ProtocolTypes();
23 // Default initialize all the type trackers. 24 // Default initialize all the type trackers.
24 for (ModelTypeSet::Iterator it = protocol_types.First(); it.Good(); 25 for (ModelTypeSet::Iterator it = protocol_types.First(); it.Good();
25 it.Inc()) { 26 it.Inc()) {
26 invalidation::ObjectId id; 27 invalidation::ObjectId id;
27 if (!RealModelTypeToObjectId(it.Get(), &id)) { 28 if (!RealModelTypeToObjectId(it.Get(), &id)) {
28 NOTREACHED(); 29 NOTREACHED();
29 } else { 30 } else {
(...skipping 19 matching lines...) Expand all
49 return true; 50 return true;
50 for (TypeTrackerMap::const_iterator it = type_trackers_.begin(); 51 for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
51 it != type_trackers_.end(); ++it) { 52 it != type_trackers_.end(); ++it) {
52 if (it->second.IsGetUpdatesRequired()) { 53 if (it->second.IsGetUpdatesRequired()) {
53 return true; 54 return true;
54 } 55 }
55 } 56 }
56 return false; 57 return false;
57 } 58 }
58 59
60 bool NudgeTracker::IsRetryRequired() const {
61 return !next_retry_time_.is_null() && next_retry_time_ < clock_->Now();
rlarocque 2014/01/06 23:00:33 I'd strongly prefer to have the base::Time value p
haitaol1 2014/01/07 19:03:37 I feel the other way. Using a clock member has the
rlarocque 2014/01/07 19:43:41 It's not quite the same, though. One trick we can
62 }
63
59 void NudgeTracker::RecordSuccessfulSyncCycle() { 64 void NudgeTracker::RecordSuccessfulSyncCycle() {
60 updates_source_ = sync_pb::GetUpdatesCallerInfo::UNKNOWN; 65 updates_source_ = sync_pb::GetUpdatesCallerInfo::UNKNOWN;
66 last_successful_sync_time_ = clock_->Now();
67
68 if (next_retry_time_ < clock_->Now())
69 next_retry_time_ = base::Time();
61 70
62 // A successful cycle while invalidations are enabled puts us back into sync. 71 // A successful cycle while invalidations are enabled puts us back into sync.
63 invalidations_out_of_sync_ = !invalidations_enabled_; 72 invalidations_out_of_sync_ = !invalidations_enabled_;
64 73
65 for (TypeTrackerMap::iterator it = type_trackers_.begin(); 74 for (TypeTrackerMap::iterator it = type_trackers_.begin();
66 it != type_trackers_.end(); ++it) { 75 it != type_trackers_.end(); ++it) {
67 it->second.RecordSuccessfulSyncCycle(); 76 it->second.RecordSuccessfulSyncCycle();
68 } 77 }
69 } 78 }
70 79
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 238
230 void NudgeTracker::SetHintBufferSize(size_t size) { 239 void NudgeTracker::SetHintBufferSize(size_t size) {
231 for (TypeTrackerMap::iterator it = type_trackers_.begin(); 240 for (TypeTrackerMap::iterator it = type_trackers_.begin();
232 it != type_trackers_.end(); ++it) { 241 it != type_trackers_.end(); ++it) {
233 it->second.UpdatePayloadBufferSize(size); 242 it->second.UpdatePayloadBufferSize(size);
234 } 243 }
235 } 244 }
236 245
237 } // namespace sessions 246 } // namespace sessions
238 } // namespace syncer 247 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698