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

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

Issue 146113003: sync: GU retry with less explicit TimeTicks logic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more comment update Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 // A class to track the outstanding work required to bring the client back into 5 // A class to track the outstanding work required to bring the client back into
6 // sync with the server. 6 // sync with the server.
7 #ifndef SYNC_SESSIONS_NUDGE_TRACKER_H_ 7 #ifndef SYNC_SESSIONS_NUDGE_TRACKER_H_
8 #define SYNC_SESSIONS_NUDGE_TRACKER_H_ 8 #define SYNC_SESSIONS_NUDGE_TRACKER_H_
9 9
10 #include <list> 10 #include <list>
(...skipping 18 matching lines...) Expand all
29 NudgeTracker(); 29 NudgeTracker();
30 ~NudgeTracker(); 30 ~NudgeTracker();
31 31
32 // Returns true if there is a good reason for performing a sync cycle. 32 // Returns true if there is a good reason for performing a sync cycle.
33 // This does not take into account whether or not this is a good *time* to 33 // This does not take into account whether or not this is a good *time* to
34 // perform a sync cycle; that's the scheduler's job. 34 // perform a sync cycle; that's the scheduler's job.
35 bool IsSyncRequired() const; 35 bool IsSyncRequired() const;
36 36
37 // Returns true if there is a good reason for performing a get updates 37 // Returns true if there is a good reason for performing a get updates
38 // request as part of the next sync cycle. 38 // request as part of the next sync cycle.
39 bool IsGetUpdatesRequired(base::TimeTicks now) const; 39 bool IsGetUpdatesRequired() const;
40 40
41 // Return true if should perform a sync cycle for GU retry. 41 // Return true if should perform a sync cycle for GU retry.
42 bool IsRetryRequired(base::TimeTicks now) const; 42 //
43 // This is sensitive to changes in 'current time'. Its value can be affected
44 // by SetSyncCycleStartTime(), SetNextRetryTime(), and
45 // RecordSuccessfulSyncCycle(). Please refer to those functions for more
46 // information on how this flag is maintained.
47 bool IsRetryRequired() const;
43 48
44 // Tells this class that all required update fetching or committing has 49 // Tells this class that all required update fetching or committing has
45 // completed successfully. 50 // completed successfully.
46 void RecordSuccessfulSyncCycle(base::TimeTicks now); 51 void RecordSuccessfulSyncCycle();
47 52
48 // Takes note of a local change. 53 // Takes note of a local change.
49 void RecordLocalChange(ModelTypeSet types); 54 void RecordLocalChange(ModelTypeSet types);
50 55
51 // Takes note of a locally issued request to refresh a data type. 56 // Takes note of a locally issued request to refresh a data type.
52 void RecordLocalRefreshRequest(ModelTypeSet types); 57 void RecordLocalRefreshRequest(ModelTypeSet types);
53 58
54 // Takes note of the receipt of an invalidation notice from the server. 59 // Takes note of the receipt of an invalidation notice from the server.
55 void RecordRemoteInvalidation( 60 void RecordRemoteInvalidation(
56 const ObjectIdInvalidationMap& invalidation_map); 61 const ObjectIdInvalidationMap& invalidation_map);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 ModelType type, 103 ModelType type,
99 sync_pb::GetUpdateTriggers* msg) const; 104 sync_pb::GetUpdateTriggers* msg) const;
100 105
101 // Fills a ProgressMarker with single legacy notification hint expected by the 106 // Fills a ProgressMarker with single legacy notification hint expected by the
102 // sync server. Newer servers will rely on the data set by FillProtoMessage() 107 // sync server. Newer servers will rely on the data set by FillProtoMessage()
103 // instead of this. 108 // instead of this.
104 void SetLegacyNotificationHint( 109 void SetLegacyNotificationHint(
105 ModelType type, 110 ModelType type,
106 sync_pb::DataTypeProgressMarker* progress) const; 111 sync_pb::DataTypeProgressMarker* progress) const;
107 112
113 // Flips the flag if we're due for a retry.
114 void SetSyncCycleStartTime(base::TimeTicks now);
115
108 // Adjusts the number of hints that can be stored locally. 116 // Adjusts the number of hints that can be stored locally.
109 void SetHintBufferSize(size_t size); 117 void SetHintBufferSize(size_t size);
110 118
111 void set_next_retry_time(base::TimeTicks next_retry_time) { 119 // Schedules a retry GetUpdate request for some time in the future.
112 next_retry_time_ = next_retry_time; 120 //
113 } 121 // This is a request sent to us as part of a server response requesting
122 // that the client perform a GetUpdate request at |next_retry_time| to
123 // fetch any updates it may have missed in the first attempt.
124 //
125 // To avoid strange results from IsRetryRequired() during a sync cycle, the
126 // effects of this change are not guaranteed to take effect until
127 // SetSyncCycleStartTime() is called at the start of the *next* sync cycle.
128 void SetNextRetryTime(base::TimeTicks next_retry_time);
114 129
115 private: 130 private:
116 typedef std::map<ModelType, DataTypeTracker> TypeTrackerMap; 131 typedef std::map<ModelType, DataTypeTracker> TypeTrackerMap;
117 132
118 TypeTrackerMap type_trackers_; 133 TypeTrackerMap type_trackers_;
119 134
120 // Merged updates source. This should be obsolete, but the server still 135 // Merged updates source. This should be obsolete, but the server still
121 // relies on it for some heuristics. 136 // relies on it for some heuristics.
122 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source_; 137 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source_;
123 138
124 // Tracks whether or not invalidations are currently enabled. 139 // Tracks whether or not invalidations are currently enabled.
125 bool invalidations_enabled_; 140 bool invalidations_enabled_;
126 141
127 // This flag is set if suspect that some technical malfunction or known bug 142 // This flag is set if suspect that some technical malfunction or known bug
128 // may have left us with some unserviced invalidations. 143 // may have left us with some unserviced invalidations.
129 // 144 //
130 // Keeps track of whether or not we're fully in sync with the invalidation 145 // Keeps track of whether or not we're fully in sync with the invalidation
131 // server. This can be false even if invalidations are enabled and working 146 // server. This can be false even if invalidations are enabled and working
132 // correctly. For example, until we get ack-tracking working properly, we 147 // correctly. For example, until we get ack-tracking working properly, we
133 // won't persist invalidations between restarts, so we may be out of sync when 148 // won't persist invalidations between restarts, so we may be out of sync when
134 // we restart. The only way to get back into sync is to have invalidations 149 // we restart. The only way to get back into sync is to have invalidations
135 // enabled, then complete a sync cycle to make sure we're fully up to date. 150 // enabled, then complete a sync cycle to make sure we're fully up to date.
136 bool invalidations_out_of_sync_; 151 bool invalidations_out_of_sync_;
137 152
138 size_t num_payloads_per_type_; 153 size_t num_payloads_per_type_;
139 154
140 base::TimeTicks last_successful_sync_time_; 155 base::TimeTicks last_successful_sync_time_;
141 156
142 // A retry GU should be issued after this time. 157 // A pending update to the current_retry_time_.
158 //
159 // The GU retry time is specified by a call to SetNextRetryTime, but we don't
160 // want that change to take effect right away, since it could happen in the
161 // middle of a sync cycle. We delay the update until the start of the next
162 // sync cycle, which is indicated by a call to SetSyncCycleStartTime().
143 base::TimeTicks next_retry_time_; 163 base::TimeTicks next_retry_time_;
144 164
165 // The currently active retry GU time. Will be null if there is no retry GU
166 // pending at this time.
167 base::TimeTicks current_retry_time_;
168
169 // The time when the sync cycle started. This value is maintained by
170 // SetSyncCycleStartTime(). This may contain a stale value if we're not
171 // currently in a sync cycle.
172 base::TimeTicks sync_cycle_start_time_;
173
145 DISALLOW_COPY_AND_ASSIGN(NudgeTracker); 174 DISALLOW_COPY_AND_ASSIGN(NudgeTracker);
146 }; 175 };
147 176
148 } // namespace sessions 177 } // namespace sessions
149 } // namespace syncer 178 } // namespace syncer
150 179
151 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_ 180 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698