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

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 10 matching lines...) Expand all
40 if (it->second.IsSyncRequired()) { 41 if (it->second.IsSyncRequired()) {
41 return true; 42 return true;
42 } 43 }
43 } 44 }
44 return false; 45 return false;
45 } 46 }
46 47
47 bool NudgeTracker::IsGetUpdatesRequired() const { 48 bool NudgeTracker::IsGetUpdatesRequired() const {
48 if (invalidations_out_of_sync_) 49 if (invalidations_out_of_sync_)
49 return true; 50 return true;
51
52 if (IsRetryRequired())
53 return true;
54
50 for (TypeTrackerMap::const_iterator it = type_trackers_.begin(); 55 for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
51 it != type_trackers_.end(); ++it) { 56 it != type_trackers_.end(); ++it) {
52 if (it->second.IsGetUpdatesRequired()) { 57 if (it->second.IsGetUpdatesRequired()) {
53 return true; 58 return true;
54 } 59 }
55 } 60 }
56 return false; 61 return false;
57 } 62 }
58 63
64 bool NudgeTracker::IsRetryRequired() const {
65 return !next_retry_time_.is_null() && next_retry_time_ < clock_->Now();
66 }
67
59 void NudgeTracker::RecordSuccessfulSyncCycle() { 68 void NudgeTracker::RecordSuccessfulSyncCycle() {
60 updates_source_ = sync_pb::GetUpdatesCallerInfo::UNKNOWN; 69 updates_source_ = sync_pb::GetUpdatesCallerInfo::UNKNOWN;
70 last_successful_sync_time_ = clock_->Now();
71
72 if (next_retry_time_ < clock_->Now())
73 next_retry_time_ = base::Time();
61 74
62 // A successful cycle while invalidations are enabled puts us back into sync. 75 // A successful cycle while invalidations are enabled puts us back into sync.
63 invalidations_out_of_sync_ = !invalidations_enabled_; 76 invalidations_out_of_sync_ = !invalidations_enabled_;
64 77
65 for (TypeTrackerMap::iterator it = type_trackers_.begin(); 78 for (TypeTrackerMap::iterator it = type_trackers_.begin();
66 it != type_trackers_.end(); ++it) { 79 it != type_trackers_.end(); ++it) {
67 it->second.RecordSuccessfulSyncCycle(); 80 it->second.RecordSuccessfulSyncCycle();
68 } 81 }
69 } 82 }
70 83
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 type_trackers_.find(type)->second.FillGetUpdatesTriggersMessage(msg); 240 type_trackers_.find(type)->second.FillGetUpdatesTriggersMessage(msg);
228 } 241 }
229 242
230 void NudgeTracker::SetHintBufferSize(size_t size) { 243 void NudgeTracker::SetHintBufferSize(size_t size) {
231 for (TypeTrackerMap::iterator it = type_trackers_.begin(); 244 for (TypeTrackerMap::iterator it = type_trackers_.begin();
232 it != type_trackers_.end(); ++it) { 245 it != type_trackers_.end(); ++it) {
233 it->second.UpdatePayloadBufferSize(size); 246 it->second.UpdatePayloadBufferSize(size);
234 } 247 }
235 } 248 }
236 249
250 void NudgeTracker::RecordSuccessfulRetry() {
251
252 }
253
237 } // namespace sessions 254 } // namespace sessions
238 } // namespace syncer 255 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698