| 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 #ifndef SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ | 5 #ifndef SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ |
| 6 #define SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ | 6 #define SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // A class to track the per-type scheduling data. | 24 // A class to track the per-type scheduling data. |
| 25 class DataTypeTracker { | 25 class DataTypeTracker { |
| 26 public: | 26 public: |
| 27 explicit DataTypeTracker(); | 27 explicit DataTypeTracker(); |
| 28 ~DataTypeTracker(); | 28 ~DataTypeTracker(); |
| 29 | 29 |
| 30 // For STL compatibility, we do not forbid the creation of a default copy | 30 // For STL compatibility, we do not forbid the creation of a default copy |
| 31 // constructor and assignment operator. | 31 // constructor and assignment operator. |
| 32 | 32 |
| 33 // Tracks that a local change has been made to this type. | 33 // Tracks that a local change has been made to this type. |
| 34 void RecordLocalChange(); | 34 // Returns the current local change nudge delay for this type. |
| 35 base::TimeDelta RecordLocalChange(); |
| 35 | 36 |
| 36 // Tracks that a local refresh request has been made for this type. | 37 // Tracks that a local refresh request has been made for this type. |
| 37 void RecordLocalRefreshRequest(); | 38 void RecordLocalRefreshRequest(); |
| 38 | 39 |
| 39 // Tracks that we received invalidation notifications for this type. | 40 // Tracks that we received invalidation notifications for this type. |
| 40 void RecordRemoteInvalidation(scoped_ptr<InvalidationInterface> incoming); | 41 void RecordRemoteInvalidation(scoped_ptr<InvalidationInterface> incoming); |
| 41 | 42 |
| 42 // Takes note that initial sync is pending for this type. | 43 // Takes note that initial sync is pending for this type. |
| 43 void RecordInitialSyncRequired(); | 44 void RecordInitialSyncRequired(); |
| 44 | 45 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // be called unless IsThrottled() returns true. The returned value will be | 90 // be called unless IsThrottled() returns true. The returned value will be |
| 90 // increased to zero if it would otherwise have been negative. | 91 // increased to zero if it would otherwise have been negative. |
| 91 base::TimeDelta GetTimeUntilUnthrottle(base::TimeTicks now) const; | 92 base::TimeDelta GetTimeUntilUnthrottle(base::TimeTicks now) const; |
| 92 | 93 |
| 93 // Throttles the type from |now| until |now| + |duration|. | 94 // Throttles the type from |now| until |now| + |duration|. |
| 94 void ThrottleType(base::TimeDelta duration, base::TimeTicks now); | 95 void ThrottleType(base::TimeDelta duration, base::TimeTicks now); |
| 95 | 96 |
| 96 // Unthrottles the type if |now| >= the throttle expiry time. | 97 // Unthrottles the type if |now| >= the throttle expiry time. |
| 97 void UpdateThrottleState(base::TimeTicks now); | 98 void UpdateThrottleState(base::TimeTicks now); |
| 98 | 99 |
| 100 // Update the local change nudge delay for this type. |
| 101 void UpdateLocalNudgeDelay(base::TimeDelta delay); |
| 102 |
| 99 private: | 103 private: |
| 100 // Number of local change nudges received for this type since the last | 104 // Number of local change nudges received for this type since the last |
| 101 // successful sync cycle. | 105 // successful sync cycle. |
| 102 int local_nudge_count_; | 106 int local_nudge_count_; |
| 103 | 107 |
| 104 // Number of local refresh requests received for this type since the last | 108 // Number of local refresh requests received for this type since the last |
| 105 // successful sync cycle. | 109 // successful sync cycle. |
| 106 int local_refresh_request_count_; | 110 int local_refresh_request_count_; |
| 107 | 111 |
| 108 // The list of invalidations received since the last successful sync cycle. | 112 // The list of invalidations received since the last successful sync cycle. |
| 109 // This list may be incomplete. See also: | 113 // This list may be incomplete. See also: |
| 110 // drop_tracker_.IsRecoveringFromDropEvent() and server_payload_overflow_. | 114 // drop_tracker_.IsRecoveringFromDropEvent() and server_payload_overflow_. |
| 111 // | 115 // |
| 112 // This list takes ownership of its contents. | 116 // This list takes ownership of its contents. |
| 113 ScopedVector<InvalidationInterface> pending_invalidations_; | 117 ScopedVector<InvalidationInterface> pending_invalidations_; |
| 114 | 118 |
| 115 size_t payload_buffer_size_; | 119 size_t payload_buffer_size_; |
| 116 | 120 |
| 117 // Set to true if this type is ready for, but has not yet completed initial | 121 // Set to true if this type is ready for, but has not yet completed initial |
| 118 // sync. | 122 // sync. |
| 119 bool initial_sync_required_; | 123 bool initial_sync_required_; |
| 120 | 124 |
| 121 // If !unthrottle_time_.is_null(), this type is throttled and may not download | 125 // If !unthrottle_time_.is_null(), this type is throttled and may not download |
| 122 // or commit data until the specified time. | 126 // or commit data until the specified time. |
| 123 base::TimeTicks unthrottle_time_; | 127 base::TimeTicks unthrottle_time_; |
| 124 | 128 |
| 125 // A helper to keep track invalidations we dropped due to overflow. | 129 // A helper to keep track invalidations we dropped due to overflow. |
| 126 scoped_ptr<InvalidationInterface> last_dropped_invalidation_; | 130 scoped_ptr<InvalidationInterface> last_dropped_invalidation_; |
| 127 | 131 |
| 132 // The amount of time to delay a sync cycle by when a local change for this |
| 133 // type occurs. |
| 134 base::TimeDelta nudge_delay_; |
| 135 |
| 128 DISALLOW_COPY_AND_ASSIGN(DataTypeTracker); | 136 DISALLOW_COPY_AND_ASSIGN(DataTypeTracker); |
| 129 }; | 137 }; |
| 130 | 138 |
| 131 } // namespace sessions | 139 } // namespace sessions |
| 132 } // namespace syncer | 140 } // namespace syncer |
| 133 | 141 |
| 134 #endif // SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ | 142 #endif // SYNC_SESSIONS_DATA_TYPE_TRACKER_H_ |
| OLD | NEW |