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