| 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 #include "components/sync/engine_impl/sync_scheduler_impl.h" | 5 #include "components/sync/engine_impl/sync_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace. | 288 } // namespace. |
| 289 | 289 |
| 290 void SyncSchedulerImpl::ScheduleConfiguration( | 290 void SyncSchedulerImpl::ScheduleConfiguration( |
| 291 const ConfigurationParams& params) { | 291 const ConfigurationParams& params) { |
| 292 DCHECK(CalledOnValidThread()); | 292 DCHECK(CalledOnValidThread()); |
| 293 DCHECK(IsConfigRelatedUpdateSourceValue(params.source)); | 293 DCHECK(IsConfigRelatedUpdateSourceValue(params.source)); |
| 294 DCHECK_EQ(CONFIGURATION_MODE, mode_); | 294 DCHECK_EQ(CONFIGURATION_MODE, mode_); |
| 295 DCHECK(!params.ready_task.is_null()); | 295 DCHECK(!params.ready_task.is_null()); |
| 296 CHECK(started_) << "Scheduler must be running to configure."; | 296 // Scheduler must be running to configure. |
| 297 CHECK(started_); |
| 297 SDVLOG(2) << "Reconfiguring syncer."; | 298 SDVLOG(2) << "Reconfiguring syncer."; |
| 298 | 299 |
| 299 // Only one configuration is allowed at a time. Verify we're not waiting | 300 // Only one configuration is allowed at a time. Verify we're not waiting |
| 300 // for a pending configure job. | 301 // for a pending configure job. |
| 301 DCHECK(!pending_configure_params_); | 302 DCHECK(!pending_configure_params_); |
| 302 | 303 |
| 303 ModelSafeRoutingInfo restricted_routes; | 304 ModelSafeRoutingInfo restricted_routes; |
| 304 BuildModelSafeParams(params.types_to_download, params.routing_info, | 305 BuildModelSafeParams(params.types_to_download, params.routing_info, |
| 305 &restricted_routes); | 306 &restricted_routes); |
| 306 cycle_context_->SetRoutingInfo(restricted_routes); | 307 cycle_context_->SetRoutingInfo(restricted_routes); |
| 307 | 308 |
| 308 // Only reconfigure if we have types to download. | 309 // Only reconfigure if we have types to download. |
| 309 if (!params.types_to_download.Empty()) { | 310 if (!params.types_to_download.Empty()) { |
| 310 pending_configure_params_ = base::MakeUnique<ConfigurationParams>(params); | 311 pending_configure_params_ = base::MakeUnique<ConfigurationParams>(params); |
| 311 TrySyncCycleJob(); | 312 TrySyncCycleJob(); |
| 312 } else { | 313 } else { |
| 313 SDVLOG(2) << "No change in routing info, calling ready task directly."; | 314 SDVLOG(2) << "No change in routing info, calling ready task directly."; |
| 314 params.ready_task.Run(); | 315 params.ready_task.Run(); |
| 315 } | 316 } |
| 316 } | 317 } |
| 317 | 318 |
| 318 void SyncSchedulerImpl::ScheduleClearServerData(const ClearParams& params) { | 319 void SyncSchedulerImpl::ScheduleClearServerData(const ClearParams& params) { |
| 319 DCHECK(CalledOnValidThread()); | 320 DCHECK(CalledOnValidThread()); |
| 320 DCHECK_EQ(CLEAR_SERVER_DATA_MODE, mode_); | 321 DCHECK_EQ(CLEAR_SERVER_DATA_MODE, mode_); |
| 321 DCHECK(!pending_configure_params_); | 322 DCHECK(!pending_configure_params_); |
| 322 DCHECK(!params.report_success_task.is_null()); | 323 DCHECK(!params.report_success_task.is_null()); |
| 323 CHECK(started_) << "Scheduler must be running to clear."; | 324 // Scheduler must be running to clear. |
| 325 CHECK(started_); |
| 324 pending_clear_params_ = base::MakeUnique<ClearParams>(params); | 326 pending_clear_params_ = base::MakeUnique<ClearParams>(params); |
| 325 TrySyncCycleJob(); | 327 TrySyncCycleJob(); |
| 326 } | 328 } |
| 327 | 329 |
| 328 bool SyncSchedulerImpl::CanRunJobNow(JobPriority priority) { | 330 bool SyncSchedulerImpl::CanRunJobNow(JobPriority priority) { |
| 329 DCHECK(CalledOnValidThread()); | 331 DCHECK(CalledOnValidThread()); |
| 330 if (IsCurrentlyThrottled()) { | 332 if (IsCurrentlyThrottled()) { |
| 331 SDVLOG(1) << "Unable to run a job because we're throttled."; | 333 SDVLOG(1) << "Unable to run a job because we're throttled."; |
| 332 return false; | 334 return false; |
| 333 } | 335 } |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 | 976 |
| 975 #undef SDVLOG_LOC | 977 #undef SDVLOG_LOC |
| 976 | 978 |
| 977 #undef SDVLOG | 979 #undef SDVLOG |
| 978 | 980 |
| 979 #undef SLOG | 981 #undef SLOG |
| 980 | 982 |
| 981 #undef ENUM_CASE | 983 #undef ENUM_CASE |
| 982 | 984 |
| 983 } // namespace syncer | 985 } // namespace syncer |
| OLD | NEW |