| 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 "sync/engine/sync_scheduler_impl.h" | 5 #include "sync/engine/sync_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "sync/engine/backoff_delay_provider.h" | 17 #include "sync/engine/backoff_delay_provider.h" |
| 18 #include "sync/engine/syncer.h" | 18 #include "sync/engine/syncer.h" |
| 19 #include "sync/notifier/object_id_invalidation_map.h" |
| 19 #include "sync/protocol/proto_enum_conversions.h" | 20 #include "sync/protocol/proto_enum_conversions.h" |
| 20 #include "sync/protocol/sync.pb.h" | 21 #include "sync/protocol/sync.pb.h" |
| 21 #include "sync/util/data_type_histogram.h" | 22 #include "sync/util/data_type_histogram.h" |
| 22 #include "sync/util/logging.h" | 23 #include "sync/util/logging.h" |
| 23 | 24 |
| 24 using base::TimeDelta; | 25 using base::TimeDelta; |
| 25 using base::TimeTicks; | 26 using base::TimeTicks; |
| 26 | 27 |
| 27 namespace syncer { | 28 namespace syncer { |
| 28 | 29 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 383 |
| 383 SDVLOG_LOC(nudge_location, 2) | 384 SDVLOG_LOC(nudge_location, 2) |
| 384 << "Scheduling sync because of local refresh request for " | 385 << "Scheduling sync because of local refresh request for " |
| 385 << ModelTypeSetToString(types); | 386 << ModelTypeSetToString(types); |
| 386 nudge_tracker_.RecordLocalRefreshRequest(types); | 387 nudge_tracker_.RecordLocalRefreshRequest(types); |
| 387 ScheduleNudgeImpl(desired_delay, nudge_location); | 388 ScheduleNudgeImpl(desired_delay, nudge_location); |
| 388 } | 389 } |
| 389 | 390 |
| 390 void SyncSchedulerImpl::ScheduleInvalidationNudge( | 391 void SyncSchedulerImpl::ScheduleInvalidationNudge( |
| 391 const TimeDelta& desired_delay, | 392 const TimeDelta& desired_delay, |
| 392 const ModelTypeInvalidationMap& invalidation_map, | 393 const ObjectIdInvalidationMap& invalidation_map, |
| 393 const tracked_objects::Location& nudge_location) { | 394 const tracked_objects::Location& nudge_location) { |
| 394 DCHECK(CalledOnValidThread()); | 395 DCHECK(CalledOnValidThread()); |
| 395 DCHECK(!invalidation_map.empty()); | 396 DCHECK(!invalidation_map.empty()); |
| 396 | 397 |
| 397 SDVLOG_LOC(nudge_location, 2) | 398 SDVLOG_LOC(nudge_location, 2) |
| 398 << "Scheduling sync because we received invalidation for " | 399 << "Scheduling sync because we received invalidation for " |
| 399 << ModelTypeInvalidationMapToString(invalidation_map); | 400 << ModelTypeSetToString(ObjectIdSetToModelTypeSet( |
| 401 ObjectIdInvalidationMapToSet(invalidation_map))); |
| 400 nudge_tracker_.RecordRemoteInvalidation(invalidation_map); | 402 nudge_tracker_.RecordRemoteInvalidation(invalidation_map); |
| 401 ScheduleNudgeImpl(desired_delay, nudge_location); | 403 ScheduleNudgeImpl(desired_delay, nudge_location); |
| 402 } | 404 } |
| 403 | 405 |
| 404 // TODO(zea): Consider adding separate throttling/backoff for datatype | 406 // TODO(zea): Consider adding separate throttling/backoff for datatype |
| 405 // refresh requests. | 407 // refresh requests. |
| 406 void SyncSchedulerImpl::ScheduleNudgeImpl( | 408 void SyncSchedulerImpl::ScheduleNudgeImpl( |
| 407 const TimeDelta& delay, | 409 const TimeDelta& delay, |
| 408 const tracked_objects::Location& nudge_location) { | 410 const tracked_objects::Location& nudge_location) { |
| 409 DCHECK(CalledOnValidThread()); | 411 DCHECK(CalledOnValidThread()); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 delay_provider_->GetInitialDelay(model_neutral_state)); | 547 delay_provider_->GetInitialDelay(model_neutral_state)); |
| 546 wait_interval_.reset( | 548 wait_interval_.reset( |
| 547 new WaitInterval(WaitInterval::EXPONENTIAL_BACKOFF, length)); | 549 new WaitInterval(WaitInterval::EXPONENTIAL_BACKOFF, length)); |
| 548 SDVLOG(2) << "Sync cycle failed. Will back off for " | 550 SDVLOG(2) << "Sync cycle failed. Will back off for " |
| 549 << wait_interval_->length.InMilliseconds() << "ms."; | 551 << wait_interval_->length.InMilliseconds() << "ms."; |
| 550 RestartWaiting(); | 552 RestartWaiting(); |
| 551 } | 553 } |
| 552 } | 554 } |
| 553 | 555 |
| 554 void SyncSchedulerImpl::DoPollSyncSessionJob() { | 556 void SyncSchedulerImpl::DoPollSyncSessionJob() { |
| 555 ModelSafeRoutingInfo r; | |
| 556 ModelTypeInvalidationMap invalidation_map = | |
| 557 ModelSafeRoutingInfoToInvalidationMap(r, std::string()); | |
| 558 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); | 557 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); |
| 559 | 558 |
| 560 if (!CanRunJobNow(NORMAL_PRIORITY)) { | 559 if (!CanRunJobNow(NORMAL_PRIORITY)) { |
| 561 SDVLOG(2) << "Unable to run a poll job right now."; | 560 SDVLOG(2) << "Unable to run a poll job right now."; |
| 562 return; | 561 return; |
| 563 } | 562 } |
| 564 | 563 |
| 565 if (mode_ != NORMAL_MODE) { | 564 if (mode_ != NORMAL_MODE) { |
| 566 SDVLOG(2) << "Not running poll job in configure mode."; | 565 SDVLOG(2) << "Not running poll job in configure mode."; |
| 567 return; | 566 return; |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 | 902 |
| 904 #undef SDVLOG_LOC | 903 #undef SDVLOG_LOC |
| 905 | 904 |
| 906 #undef SDVLOG | 905 #undef SDVLOG |
| 907 | 906 |
| 908 #undef SLOG | 907 #undef SLOG |
| 909 | 908 |
| 910 #undef ENUM_CASE | 909 #undef ENUM_CASE |
| 911 | 910 |
| 912 } // namespace syncer | 911 } // namespace syncer |
| OLD | NEW |