OLD | NEW |
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 Loading... |
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() const; | 39 bool IsGetUpdatesRequired(base::TimeTicks now) const; |
40 | 40 |
41 // Tells this class that all required update fetching and committing has | 41 // Return true if should perform a sync cycle for GU retry. |
| 42 bool IsRetryRequired(base::TimeTicks now) const; |
| 43 |
| 44 // Tells this class that all required update fetching or committing has |
42 // completed successfully. | 45 // completed successfully. |
43 void RecordSuccessfulSyncCycle(); | 46 void RecordSuccessfulSyncCycle(base::TimeTicks now); |
44 | 47 |
45 // Takes note of a local change. | 48 // Takes note of a local change. |
46 void RecordLocalChange(ModelTypeSet types); | 49 void RecordLocalChange(ModelTypeSet types); |
47 | 50 |
48 // Takes note of a locally issued request to refresh a data type. | 51 // Takes note of a locally issued request to refresh a data type. |
49 void RecordLocalRefreshRequest(ModelTypeSet types); | 52 void RecordLocalRefreshRequest(ModelTypeSet types); |
50 | 53 |
51 // Takes note of the receipt of an invalidation notice from the server. | 54 // Takes note of the receipt of an invalidation notice from the server. |
52 void RecordRemoteInvalidation( | 55 void RecordRemoteInvalidation( |
53 const ObjectIdInvalidationMap& invalidation_map); | 56 const ObjectIdInvalidationMap& invalidation_map); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Fills a ProgressMarker with single legacy notification hint expected by the | 101 // Fills a ProgressMarker with single legacy notification hint expected by the |
99 // sync server. Newer servers will rely on the data set by FillProtoMessage() | 102 // sync server. Newer servers will rely on the data set by FillProtoMessage() |
100 // instead of this. | 103 // instead of this. |
101 void SetLegacyNotificationHint( | 104 void SetLegacyNotificationHint( |
102 ModelType type, | 105 ModelType type, |
103 sync_pb::DataTypeProgressMarker* progress) const; | 106 sync_pb::DataTypeProgressMarker* progress) const; |
104 | 107 |
105 // Adjusts the number of hints that can be stored locally. | 108 // Adjusts the number of hints that can be stored locally. |
106 void SetHintBufferSize(size_t size); | 109 void SetHintBufferSize(size_t size); |
107 | 110 |
| 111 void set_next_retry_time(base::TimeTicks next_retry_time) { |
| 112 next_retry_time_ = next_retry_time; |
| 113 } |
| 114 |
108 private: | 115 private: |
109 typedef std::map<ModelType, DataTypeTracker> TypeTrackerMap; | 116 typedef std::map<ModelType, DataTypeTracker> TypeTrackerMap; |
110 | 117 |
111 TypeTrackerMap type_trackers_; | 118 TypeTrackerMap type_trackers_; |
112 | 119 |
113 // Merged updates source. This should be obsolete, but the server still | 120 // Merged updates source. This should be obsolete, but the server still |
114 // relies on it for some heuristics. | 121 // relies on it for some heuristics. |
115 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source_; | 122 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source_; |
116 | 123 |
117 // Tracks whether or not invalidations are currently enabled. | 124 // Tracks whether or not invalidations are currently enabled. |
118 bool invalidations_enabled_; | 125 bool invalidations_enabled_; |
119 | 126 |
120 // This flag is set if suspect that some technical malfunction or known bug | 127 // This flag is set if suspect that some technical malfunction or known bug |
121 // may have left us with some unserviced invalidations. | 128 // may have left us with some unserviced invalidations. |
122 // | 129 // |
123 // Keeps track of whether or not we're fully in sync with the invalidation | 130 // Keeps track of whether or not we're fully in sync with the invalidation |
124 // server. This can be false even if invalidations are enabled and working | 131 // server. This can be false even if invalidations are enabled and working |
125 // correctly. For example, until we get ack-tracking working properly, we | 132 // correctly. For example, until we get ack-tracking working properly, we |
126 // won't persist invalidations between restarts, so we may be out of sync when | 133 // won't persist invalidations between restarts, so we may be out of sync when |
127 // we restart. The only way to get back into sync is to have invalidations | 134 // we restart. The only way to get back into sync is to have invalidations |
128 // enabled, then complete a sync cycle to make sure we're fully up to date. | 135 // enabled, then complete a sync cycle to make sure we're fully up to date. |
129 bool invalidations_out_of_sync_; | 136 bool invalidations_out_of_sync_; |
130 | 137 |
131 size_t num_payloads_per_type_; | 138 size_t num_payloads_per_type_; |
132 | 139 |
| 140 base::TimeTicks last_successful_sync_time_; |
| 141 |
| 142 // A retry GU should be issued after this time. |
| 143 base::TimeTicks next_retry_time_; |
| 144 |
133 DISALLOW_COPY_AND_ASSIGN(NudgeTracker); | 145 DISALLOW_COPY_AND_ASSIGN(NudgeTracker); |
134 }; | 146 }; |
135 | 147 |
136 } // namespace sessions | 148 } // namespace sessions |
137 } // namespace syncer | 149 } // namespace syncer |
138 | 150 |
139 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_ | 151 #endif // SYNC_SESSIONS_NUDGE_TRACKER_H_ |
OLD | NEW |