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

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

Issue 488843002: [Sync] Add support for server controlled nudge delays (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 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
« no previous file with comments | « sync/protocol/client_commands.proto ('k') | sync/sessions/data_type_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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
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
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_
OLDNEW
« no previous file with comments | « sync/protocol/client_commands.proto ('k') | sync/sessions/data_type_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698