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

Side by Side Diff: components/sync/engine_impl/sync_scheduler_impl.h

Issue 2828423002: [Sync] Sync types never recovers from throttle (Closed)
Patch Set: rebase Created 3 years, 7 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
« no previous file with comments | « no previous file | components/sync/engine_impl/sync_scheduler_impl.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_
6 #define COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ 6 #define COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void DoPollSyncCycleJob(); 141 void DoPollSyncCycleJob();
142 142
143 // Helper function to calculate poll interval. 143 // Helper function to calculate poll interval.
144 base::TimeDelta GetPollInterval(); 144 base::TimeDelta GetPollInterval();
145 145
146 // Adjusts the poll timer to account for new poll interval, and possibly 146 // Adjusts the poll timer to account for new poll interval, and possibly
147 // resets the poll interval, depedning on the flag's value. 147 // resets the poll interval, depedning on the flag's value.
148 void AdjustPolling(PollAdjustType type); 148 void AdjustPolling(PollAdjustType type);
149 149
150 // Helper to restart pending_wakeup_timer_. 150 // Helper to restart pending_wakeup_timer_.
151 // This function need to be called in 3 conditions, backoff/throttling
152 // happens, unbackoff/unthrottling happens and after |PerformDelayedNudge|
153 // runs.
154 // This function is for scheduling unbackoff/unthrottling jobs, and the
155 // poriority is, global unbackoff/unthrottling job first, if there is no
156 // global backoff/throttling, then try to schedule types
157 // unbackoff/unthrottling job.
151 void RestartWaiting(); 158 void RestartWaiting();
152 159
153 // Determines if we're allowed to contact the server right now. 160 // Determines if we're allowed to contact the server right now.
154 bool CanRunJobNow(JobPriority priority); 161 bool CanRunJobNow(JobPriority priority);
155 162
156 // Determines if we're allowed to contact the server right now. 163 // Determines if we're allowed to contact the server right now.
157 bool CanRunNudgeJobNow(JobPriority priority); 164 bool CanRunNudgeJobNow(JobPriority priority);
158 165
159 // If the scheduler's current state supports it, this will create a job based 166 // If the scheduler's current state supports it, this will create a job based
160 // on the passed in parameters and coalesce it with any other pending jobs, 167 // on the passed in parameters and coalesce it with any other pending jobs,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // containing data like initial_sync_ended. Important when the client starts 216 // containing data like initial_sync_ended. Important when the client starts
210 // up and does not need to perform an initial sync. 217 // up and does not need to perform an initial sync.
211 void SendInitialSnapshot(); 218 void SendInitialSnapshot();
212 219
213 // This is used for histogramming and analysis of ScheduleNudge* APIs. 220 // This is used for histogramming and analysis of ScheduleNudge* APIs.
214 // SyncScheduler is the ultimate choke-point for all such invocations (with 221 // SyncScheduler is the ultimate choke-point for all such invocations (with
215 // and without InvalidationState variants, all NudgeSources, etc) and as such 222 // and without InvalidationState variants, all NudgeSources, etc) and as such
216 // is the most flexible place to do this bookkeeping. 223 // is the most flexible place to do this bookkeeping.
217 void UpdateNudgeTimeRecords(ModelTypeSet types); 224 void UpdateNudgeTimeRecords(ModelTypeSet types);
218 225
226 bool IsEarlierThanCurrentPendingJob(const base::TimeDelta& delay);
227
219 // Used for logging. 228 // Used for logging.
220 const std::string name_; 229 const std::string name_;
221 230
222 // Set in Start(), unset in Stop(). 231 // Set in Start(), unset in Stop().
223 bool started_; 232 bool started_;
224 233
225 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be 234 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be
226 // updated by the server. 235 // updated by the server.
227 base::TimeDelta syncer_short_poll_interval_seconds_; 236 base::TimeDelta syncer_short_poll_interval_seconds_;
228 base::TimeDelta syncer_long_poll_interval_seconds_; 237 base::TimeDelta syncer_long_poll_interval_seconds_;
229 238
230 // Timer for polling. Restarted on each successful poll, and when entering 239 // Timer for polling. Restarted on each successful poll, and when entering
231 // normal sync mode or exiting an error state. Not active in configuration 240 // normal sync mode or exiting an error state. Not active in configuration
232 // mode. 241 // mode.
233 base::OneShotTimer poll_timer_; 242 base::OneShotTimer poll_timer_;
234 243
235 // The mode of operation. 244 // The mode of operation.
236 Mode mode_; 245 Mode mode_;
237 246
238 // Current wait state. Null if we're not in backoff and not throttled. 247 // Current wait state. Null if we're not in backoff and not throttled.
239 std::unique_ptr<WaitInterval> wait_interval_; 248 std::unique_ptr<WaitInterval> wait_interval_;
240 249
241 std::unique_ptr<BackoffDelayProvider> delay_provider_; 250 std::unique_ptr<BackoffDelayProvider> delay_provider_;
242 251
252 // TODO(gangwu): http://crbug.com/714868 too many timers in this class, try to
253 // reduce them.
243 // The event that will wake us up. 254 // The event that will wake us up.
244 // When the whole client got throttling or backoff, we will delay this timer 255 // When the whole client got throttling or backoff, we will delay this timer
245 // as well. 256 // as well.
246 base::OneShotTimer pending_wakeup_timer_; 257 base::OneShotTimer pending_wakeup_timer_;
247 258
248 // Storage for variables related to an in-progress configure request. Note 259 // Storage for variables related to an in-progress configure request. Note
249 // that (mode_ != CONFIGURATION_MODE) \implies !pending_configure_params_. 260 // that (mode_ != CONFIGURATION_MODE) \implies !pending_configure_params_.
250 std::unique_ptr<ConfigurationParams> pending_configure_params_; 261 std::unique_ptr<ConfigurationParams> pending_configure_params_;
251 262
252 std::unique_ptr<ClearParams> pending_clear_params_; 263 std::unique_ptr<ClearParams> pending_clear_params_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 bool ignore_auth_credentials_; 295 bool ignore_auth_credentials_;
285 296
286 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; 297 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_;
287 298
288 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); 299 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl);
289 }; 300 };
290 301
291 } // namespace syncer 302 } // namespace syncer
292 303
293 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ 304 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | components/sync/engine_impl/sync_scheduler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698