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

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

Issue 463563005: sync: Attempt to fix sync scheduler test flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase fixes + add comment Created 6 years, 4 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/engine/sync_scheduler_unittest.cc ('k') | no next file » | 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/protocol/sync.pb.h" 8 #include "sync/protocol/sync.pb.h"
9 9
10 namespace syncer { 10 namespace syncer {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return false; 56 return false;
57 } 57 }
58 58
59 bool NudgeTracker::IsRetryRequired() const { 59 bool NudgeTracker::IsRetryRequired() const {
60 if (sync_cycle_start_time_.is_null()) 60 if (sync_cycle_start_time_.is_null())
61 return false; 61 return false;
62 62
63 if (current_retry_time_.is_null()) 63 if (current_retry_time_.is_null())
64 return false; 64 return false;
65 65
66 return current_retry_time_ < sync_cycle_start_time_; 66 return current_retry_time_ <= sync_cycle_start_time_;
67 } 67 }
68 68
69 void NudgeTracker::RecordSuccessfulSyncCycle() { 69 void NudgeTracker::RecordSuccessfulSyncCycle() {
70 // If a retry was required, we've just serviced it. Unset the flag. 70 // If a retry was required, we've just serviced it. Unset the flag.
71 if (IsRetryRequired()) 71 if (IsRetryRequired())
72 current_retry_time_ = base::TimeTicks(); 72 current_retry_time_ = base::TimeTicks();
73 73
74 // A successful cycle while invalidations are enabled puts us back into sync. 74 // A successful cycle while invalidations are enabled puts us back into sync.
75 invalidations_out_of_sync_ = !invalidations_enabled_; 75 invalidations_out_of_sync_ = !invalidations_enabled_;
76 76
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // flag so we leave this variable set regardless of whether or not there is an 293 // flag so we leave this variable set regardless of whether or not there is an
294 // overwrite pending. 294 // overwrite pending.
295 if (!current_retry_time_.is_null()) { 295 if (!current_retry_time_.is_null()) {
296 return; 296 return;
297 } 297 }
298 298
299 // If do not have a current_retry_time_, but we do have a next_retry_time_ and 299 // If do not have a current_retry_time_, but we do have a next_retry_time_ and
300 // it is ready to go, then we set it as the current_retry_time_. It will stay 300 // it is ready to go, then we set it as the current_retry_time_. It will stay
301 // there until a GU retry has succeeded. 301 // there until a GU retry has succeeded.
302 if (!next_retry_time_.is_null() && 302 if (!next_retry_time_.is_null() &&
303 next_retry_time_ < sync_cycle_start_time_) { 303 next_retry_time_ <= sync_cycle_start_time_) {
304 current_retry_time_ = next_retry_time_; 304 current_retry_time_ = next_retry_time_;
305 next_retry_time_ = base::TimeTicks(); 305 next_retry_time_ = base::TimeTicks();
306 } 306 }
307 } 307 }
308 308
309 void NudgeTracker::SetHintBufferSize(size_t size) { 309 void NudgeTracker::SetHintBufferSize(size_t size) {
310 for (TypeTrackerMap::iterator it = type_trackers_.begin(); 310 for (TypeTrackerMap::iterator it = type_trackers_.begin();
311 it != type_trackers_.end(); ++it) { 311 it != type_trackers_.end(); ++it) {
312 it->second->UpdatePayloadBufferSize(size); 312 it->second->UpdatePayloadBufferSize(size);
313 } 313 }
314 } 314 }
315 315
316 void NudgeTracker::SetNextRetryTime(base::TimeTicks retry_time) { 316 void NudgeTracker::SetNextRetryTime(base::TimeTicks retry_time) {
317 next_retry_time_ = retry_time; 317 next_retry_time_ = retry_time;
318 } 318 }
319 319
320 } // namespace sessions 320 } // namespace sessions
321 } // namespace syncer 321 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698