| OLD | NEW |
| 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 SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ |
| 6 #define SYNC_ENGINE_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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
| 22 #include "sync/base/sync_export.h" | 22 #include "components/sync/base/sync_export.h" |
| 23 #include "sync/engine/net/server_connection_manager.h" | 23 #include "components/sync/base/weak_handle.h" |
| 24 #include "sync/engine/nudge_source.h" | 24 #include "components/sync/engine/polling_constants.h" |
| 25 #include "sync/engine/sync_scheduler.h" | 25 #include "components/sync/engine_impl/net/server_connection_manager.h" |
| 26 #include "sync/engine/syncer.h" | 26 #include "components/sync/engine_impl/nudge_source.h" |
| 27 #include "sync/internal_api/public/engine/polling_constants.h" | 27 #include "components/sync/engine_impl/sync_scheduler.h" |
| 28 #include "sync/internal_api/public/util/weak_handle.h" | 28 #include "components/sync/engine_impl/syncer.h" |
| 29 #include "sync/sessions/nudge_tracker.h" | 29 #include "components/sync/sessions_impl/nudge_tracker.h" |
| 30 #include "sync/sessions/sync_session.h" | 30 #include "components/sync/sessions_impl/sync_session.h" |
| 31 #include "sync/sessions/sync_session_context.h" | 31 #include "components/sync/sessions_impl/sync_session_context.h" |
| 32 | 32 |
| 33 namespace syncer { | 33 namespace syncer { |
| 34 | 34 |
| 35 class BackoffDelayProvider; | 35 class BackoffDelayProvider; |
| 36 | 36 |
| 37 namespace sessions { | 37 namespace sessions { |
| 38 struct ModelNeutralState; | 38 struct ModelNeutralState; |
| 39 } | 39 } |
| 40 | 40 |
| 41 class SYNC_EXPORT SyncSchedulerImpl : public SyncScheduler, | 41 class SYNC_EXPORT SyncSchedulerImpl : public SyncScheduler, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 // Invoke the syncer to perform a configuration job. | 152 // Invoke the syncer to perform a configuration job. |
| 153 void DoConfigurationSyncSessionJob(JobPriority priority); | 153 void DoConfigurationSyncSessionJob(JobPriority priority); |
| 154 | 154 |
| 155 void DoClearServerDataSyncSessionJob(JobPriority priority); | 155 void DoClearServerDataSyncSessionJob(JobPriority priority); |
| 156 | 156 |
| 157 // Helper function for Do{Nudge,Configuration,Poll}SyncSessionJob. | 157 // Helper function for Do{Nudge,Configuration,Poll}SyncSessionJob. |
| 158 void HandleSuccess(); | 158 void HandleSuccess(); |
| 159 | 159 |
| 160 // Helper function for Do{Nudge,Configuration,Poll}SyncSessionJob. | 160 // Helper function for Do{Nudge,Configuration,Poll}SyncSessionJob. |
| 161 void HandleFailure( | 161 void HandleFailure(const sessions::ModelNeutralState& model_neutral_state); |
| 162 const sessions::ModelNeutralState& model_neutral_state); | |
| 163 | 162 |
| 164 // Invoke the Syncer to perform a poll job. | 163 // Invoke the Syncer to perform a poll job. |
| 165 void DoPollSyncSessionJob(); | 164 void DoPollSyncSessionJob(); |
| 166 | 165 |
| 167 // Helper function to calculate poll interval. | 166 // Helper function to calculate poll interval. |
| 168 base::TimeDelta GetPollInterval(); | 167 base::TimeDelta GetPollInterval(); |
| 169 | 168 |
| 170 // Adjusts the poll timer to account for new poll interval, and possibly | 169 // Adjusts the poll timer to account for new poll interval, and possibly |
| 171 // resets the poll interval, depedning on the flag's value. | 170 // resets the poll interval, depedning on the flag's value. |
| 172 void AdjustPolling(PollAdjustType type); | 171 void AdjustPolling(PollAdjustType type); |
| 173 | 172 |
| 174 // Helper to restart waiting with |wait_interval_|'s timer. | 173 // Helper to restart waiting with |wait_interval_|'s timer. |
| 175 void RestartWaiting(); | 174 void RestartWaiting(); |
| 176 | 175 |
| 177 // Determines if we're allowed to contact the server right now. | 176 // Determines if we're allowed to contact the server right now. |
| 178 bool CanRunJobNow(JobPriority priority); | 177 bool CanRunJobNow(JobPriority priority); |
| 179 | 178 |
| 180 // Determines if we're allowed to contact the server right now. | 179 // Determines if we're allowed to contact the server right now. |
| 181 bool CanRunNudgeJobNow(JobPriority priority); | 180 bool CanRunNudgeJobNow(JobPriority priority); |
| 182 | 181 |
| 183 // If the scheduler's current state supports it, this will create a job based | 182 // If the scheduler's current state supports it, this will create a job based |
| 184 // on the passed in parameters and coalesce it with any other pending jobs, | 183 // on the passed in parameters and coalesce it with any other pending jobs, |
| 185 // then post a delayed task to run it. It may also choose to drop the job or | 184 // then post a delayed task to run it. It may also choose to drop the job or |
| 186 // save it for later, depending on the scheduler's current state. | 185 // save it for later, depending on the scheduler's current state. |
| 187 void ScheduleNudgeImpl( | 186 void ScheduleNudgeImpl(const base::TimeDelta& delay, |
| 188 const base::TimeDelta& delay, | 187 const tracked_objects::Location& nudge_location); |
| 189 const tracked_objects::Location& nudge_location); | |
| 190 | 188 |
| 191 // Helper to signal listeners about changed retry time. | 189 // Helper to signal listeners about changed retry time. |
| 192 void NotifyRetryTime(base::Time retry_time); | 190 void NotifyRetryTime(base::Time retry_time); |
| 193 | 191 |
| 194 // Helper to signal listeners about changed throttled types. | 192 // Helper to signal listeners about changed throttled types. |
| 195 void NotifyThrottledTypesChanged(ModelTypeSet types); | 193 void NotifyThrottledTypesChanged(ModelTypeSet types); |
| 196 | 194 |
| 197 // Looks for pending work and, if it finds any, run this work at "canary" | 195 // Looks for pending work and, if it finds any, run this work at "canary" |
| 198 // priority. | 196 // priority. |
| 199 void TryCanaryJob(); | 197 void TryCanaryJob(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 319 |
| 322 // A second factory specially for weak_handle_this_, to allow the handle | 320 // A second factory specially for weak_handle_this_, to allow the handle |
| 323 // to be const and alleviate threading concerns. | 321 // to be const and alleviate threading concerns. |
| 324 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; | 322 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; |
| 325 | 323 |
| 326 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); | 324 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); |
| 327 }; | 325 }; |
| 328 | 326 |
| 329 } // namespace syncer | 327 } // namespace syncer |
| 330 | 328 |
| 331 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ | 329 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNC_SCHEDULER_IMPL_H_ |
| OLD | NEW |