| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // A class to schedule syncer tasks intelligently. | 5 // A class to schedule syncer tasks intelligently. |
| 6 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_H_ | 6 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| 7 #define SYNC_ENGINE_SYNC_SCHEDULER_H_ | 7 #define SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| 8 #pragma once | 8 #pragma once |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 const tracked_objects::Location& nudge_location); | 87 const tracked_objects::Location& nudge_location); |
| 88 | 88 |
| 89 // Schedule a configuration cycle. May execute immediately or at a later time | 89 // Schedule a configuration cycle. May execute immediately or at a later time |
| 90 // (depending on backoff/throttle state). | 90 // (depending on backoff/throttle state). |
| 91 // Note: The source argument of this function must come from the subset of | 91 // Note: The source argument of this function must come from the subset of |
| 92 // GetUpdatesCallerInfo values related to configurations. | 92 // GetUpdatesCallerInfo values related to configurations. |
| 93 void ScheduleConfiguration( | 93 void ScheduleConfiguration( |
| 94 syncable::ModelTypeSet types, | 94 syncable::ModelTypeSet types, |
| 95 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 95 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 96 | 96 |
| 97 // TODO(tim): remove this. crbug.com/131336 | |
| 98 void ClearUserData(); | |
| 99 | |
| 100 void CleanupDisabledTypes(); | 97 void CleanupDisabledTypes(); |
| 101 | 98 |
| 102 // Change status of notifications in the SyncSessionContext. | 99 // Change status of notifications in the SyncSessionContext. |
| 103 void set_notifications_enabled(bool notifications_enabled); | 100 void set_notifications_enabled(bool notifications_enabled); |
| 104 | 101 |
| 105 base::TimeDelta sessions_commit_delay() const; | 102 base::TimeDelta sessions_commit_delay() const; |
| 106 | 103 |
| 107 // DDOS avoidance function. Calculates how long we should wait before trying | 104 // DDOS avoidance function. Calculates how long we should wait before trying |
| 108 // again after a failed sync attempt, where the last delay was |base_delay|. | 105 // again after a failed sync attempt, where the last delay was |base_delay|. |
| 109 // TODO(tim): Look at URLRequestThrottlerEntryInterface. | 106 // TODO(tim): Look at URLRequestThrottlerEntryInterface. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // An enum used to describe jobs for scheduling purposes. | 140 // An enum used to describe jobs for scheduling purposes. |
| 144 enum SyncSessionJobPurpose { | 141 enum SyncSessionJobPurpose { |
| 145 // Uninitialized state, should never be hit in practice. | 142 // Uninitialized state, should never be hit in practice. |
| 146 UNKNOWN = -1, | 143 UNKNOWN = -1, |
| 147 // Our poll timer schedules POLL jobs periodically based on a server | 144 // Our poll timer schedules POLL jobs periodically based on a server |
| 148 // assigned poll interval. | 145 // assigned poll interval. |
| 149 POLL, | 146 POLL, |
| 150 // A nudge task can come from a variety of components needing to force | 147 // A nudge task can come from a variety of components needing to force |
| 151 // a sync. The source is inferable from |session.source()|. | 148 // a sync. The source is inferable from |session.source()|. |
| 152 NUDGE, | 149 NUDGE, |
| 153 // The user invoked a function in the UI to clear their entire account | |
| 154 // and stop syncing (globally). | |
| 155 CLEAR_USER_DATA, | |
| 156 // Typically used for fetching updates for a subset of the enabled types | 150 // Typically used for fetching updates for a subset of the enabled types |
| 157 // during initial sync or reconfiguration. We don't run all steps of | 151 // during initial sync or reconfiguration. We don't run all steps of |
| 158 // the sync cycle for these (e.g. CleanupDisabledTypes is skipped). | 152 // the sync cycle for these (e.g. CleanupDisabledTypes is skipped). |
| 159 CONFIGURATION, | 153 CONFIGURATION, |
| 160 // The user disabled some types and we have to clean up the data | 154 // The user disabled some types and we have to clean up the data |
| 161 // for those. | 155 // for those. |
| 162 CLEANUP_DISABLED_TYPES, | 156 CLEANUP_DISABLED_TYPES, |
| 163 }; | 157 }; |
| 164 SyncSessionJob(); | 158 SyncSessionJob(); |
| 165 SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start, | 159 SyncSessionJob(SyncSessionJobPurpose purpose, base::TimeTicks start, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 189 SaveNudgeWhileTypeThrottled); | 183 SaveNudgeWhileTypeThrottled); |
| 190 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueNudge); | 184 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueNudge); |
| 191 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, DropPoll); | 185 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, DropPoll); |
| 192 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinuePoll); | 186 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinuePoll); |
| 193 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueConfiguration); | 187 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, ContinueConfiguration); |
| 194 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 188 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
| 195 SaveConfigurationWhileThrottled); | 189 SaveConfigurationWhileThrottled); |
| 196 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 190 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
| 197 SaveNudgeWhileThrottled); | 191 SaveNudgeWhileThrottled); |
| 198 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 192 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
| 199 ContinueClearUserDataUnderAllCircumstances); | |
| 200 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | |
| 201 ContinueCanaryJobConfig); | 193 ContinueCanaryJobConfig); |
| 202 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, | 194 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerWhiteboxTest, |
| 203 ContinueNudgeWhileExponentialBackOff); | 195 ContinueNudgeWhileExponentialBackOff); |
| 204 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, TransientPollFailure); | 196 FRIEND_TEST_ALL_PREFIXES(SyncSchedulerTest, TransientPollFailure); |
| 205 | 197 |
| 206 // A component used to get time delays associated with exponential backoff. | 198 // A component used to get time delays associated with exponential backoff. |
| 207 // Encapsulated into a class to facilitate testing. | 199 // Encapsulated into a class to facilitate testing. |
| 208 class DelayProvider { | 200 class DelayProvider { |
| 209 public: | 201 public: |
| 210 DelayProvider(); | 202 DelayProvider(); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 scoped_ptr<Syncer> syncer_; | 398 scoped_ptr<Syncer> syncer_; |
| 407 | 399 |
| 408 sessions::SyncSessionContext *session_context_; | 400 sessions::SyncSessionContext *session_context_; |
| 409 | 401 |
| 410 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); | 402 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); |
| 411 }; | 403 }; |
| 412 | 404 |
| 413 } // namespace browser_sync | 405 } // namespace browser_sync |
| 414 | 406 |
| 415 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ | 407 #endif // SYNC_ENGINE_SYNC_SCHEDULER_H_ |
| OLD | NEW |