Chromium Code Reviews| 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" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 const base::Closure& ready_task) | 76 const base::Closure& ready_task) |
| 77 : source(source), | 77 : source(source), |
| 78 types_to_download(types_to_download), | 78 types_to_download(types_to_download), |
| 79 routing_info(routing_info), | 79 routing_info(routing_info), |
| 80 ready_task(ready_task) { | 80 ready_task(ready_task) { |
| 81 DCHECK(!ready_task.is_null()); | 81 DCHECK(!ready_task.is_null()); |
| 82 } | 82 } |
| 83 ConfigurationParams::~ConfigurationParams() {} | 83 ConfigurationParams::~ConfigurationParams() {} |
| 84 | 84 |
| 85 SyncSchedulerImpl::WaitInterval::WaitInterval() | 85 SyncSchedulerImpl::WaitInterval::WaitInterval() |
| 86 : mode(UNKNOWN), | 86 : mode(UNKNOWN) {} |
| 87 had_nudge(false) {} | |
| 88 | 87 |
| 89 SyncSchedulerImpl::WaitInterval::WaitInterval(Mode mode, TimeDelta length) | 88 SyncSchedulerImpl::WaitInterval::WaitInterval(Mode mode, TimeDelta length) |
| 90 : mode(mode), had_nudge(false), length(length) {} | 89 : mode(mode), length(length) {} |
| 91 | 90 |
| 92 SyncSchedulerImpl::WaitInterval::~WaitInterval() {} | 91 SyncSchedulerImpl::WaitInterval::~WaitInterval() {} |
| 93 | 92 |
| 94 #define ENUM_CASE(x) case x: return #x; break; | 93 #define ENUM_CASE(x) case x: return #x; break; |
| 95 | 94 |
| 96 const char* SyncSchedulerImpl::WaitInterval::GetModeString(Mode mode) { | 95 const char* SyncSchedulerImpl::WaitInterval::GetModeString(Mode mode) { |
| 97 switch (mode) { | 96 switch (mode) { |
| 98 ENUM_CASE(UNKNOWN); | 97 ENUM_CASE(UNKNOWN); |
| 99 ENUM_CASE(EXPONENTIAL_BACKOFF); | 98 ENUM_CASE(EXPONENTIAL_BACKOFF); |
| 100 ENUM_CASE(THROTTLED); | 99 ENUM_CASE(THROTTLED); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 SDVLOG(2) << "No change in routing info, calling ready task directly."; | 309 SDVLOG(2) << "No change in routing info, calling ready task directly."; |
| 311 params.ready_task.Run(); | 310 params.ready_task.Run(); |
| 312 } | 311 } |
| 313 | 312 |
| 314 return true; | 313 return true; |
| 315 } | 314 } |
| 316 | 315 |
| 317 SyncSchedulerImpl::JobProcessDecision | 316 SyncSchedulerImpl::JobProcessDecision |
| 318 SyncSchedulerImpl::DecideWhileInWaitInterval(const SyncSessionJob& job, | 317 SyncSchedulerImpl::DecideWhileInWaitInterval(const SyncSessionJob& job, |
| 319 JobPriority priority) { | 318 JobPriority priority) { |
| 320 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 319 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
|
tim (not reviewing)
2013/04/05 16:56:44
It looks like all non-DCHECK use of sync_loop_ was
rlarocque
2013/04/05 19:13:29
Done.
| |
| 321 DCHECK(wait_interval_.get()); | 320 DCHECK(wait_interval_.get()); |
| 322 DCHECK_NE(job.purpose(), SyncSessionJob::POLL); | 321 DCHECK_NE(job.purpose(), SyncSessionJob::POLL); |
| 323 | 322 |
| 324 SDVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " | 323 SDVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " |
| 325 << WaitInterval::GetModeString(wait_interval_->mode) | 324 << WaitInterval::GetModeString(wait_interval_->mode) |
| 326 << (wait_interval_->had_nudge ? " (had nudge)" : "") | |
| 327 << ((priority == CANARY_PRIORITY) ? " (canary)" : ""); | 325 << ((priority == CANARY_PRIORITY) ? " (canary)" : ""); |
| 328 | 326 |
| 329 // If we save a job while in a WaitInterval, there is a well-defined moment | 327 // If we save a job while in a WaitInterval, there is a well-defined moment |
| 330 // in time in the future when it makes sense for that SAVE-worthy job to try | 328 // in time in the future when it makes sense for that SAVE-worthy job to try |
| 331 // running again -- the end of the WaitInterval. | 329 // running again -- the end of the WaitInterval. |
| 332 DCHECK(job.purpose() == SyncSessionJob::NUDGE || | 330 DCHECK(job.purpose() == SyncSessionJob::NUDGE || |
| 333 job.purpose() == SyncSessionJob::CONFIGURATION); | 331 job.purpose() == SyncSessionJob::CONFIGURATION); |
| 334 | 332 |
| 335 // If throttled, there's a clock ticking to unthrottle. We want to get | 333 // If throttled, there's a clock ticking to unthrottle. We want to get |
| 336 // on the same train. | 334 // on the same train. |
| 337 if (wait_interval_->mode == WaitInterval::THROTTLED) | 335 if (wait_interval_->mode == WaitInterval::THROTTLED) |
| 338 return SAVE; | 336 return SAVE; |
| 339 | 337 |
| 340 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF); | 338 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF); |
| 341 if (job.purpose() == SyncSessionJob::NUDGE) { | 339 if (job.purpose() == SyncSessionJob::NUDGE) { |
| 342 if (mode_ == CONFIGURATION_MODE) | 340 if (mode_ == CONFIGURATION_MODE) |
| 343 return SAVE; | 341 return SAVE; |
| 344 | 342 |
| 345 // If we already had one nudge then just drop this nudge. We will retry | 343 // If we already had one nudge then just drop this nudge. We will retry |
| 346 // later when the timer runs out. | 344 // later when the timer runs out. |
| 347 if (priority == NORMAL_PRIORITY) | 345 if (priority == NORMAL_PRIORITY) |
| 348 return wait_interval_->had_nudge ? DROP : CONTINUE; | 346 return DROP; |
| 349 else // We are here because timer ran out. So retry. | 347 else // We are here because timer ran out. So retry. |
|
tim (not reviewing)
2013/04/05 16:56:44
In fact this comment isn't true, so we should fix
rlarocque
2013/04/05 19:13:29
Done.
| |
| 350 return CONTINUE; | 348 return CONTINUE; |
| 351 } | 349 } |
| 352 return (priority == CANARY_PRIORITY) ? CONTINUE : SAVE; | 350 return (priority == CANARY_PRIORITY) ? CONTINUE : SAVE; |
| 353 } | 351 } |
| 354 | 352 |
| 355 SyncSchedulerImpl::JobProcessDecision SyncSchedulerImpl::DecideOnJob( | 353 SyncSchedulerImpl::JobProcessDecision SyncSchedulerImpl::DecideOnJob( |
| 356 const SyncSessionJob& job, | 354 const SyncSessionJob& job, |
| 357 JobPriority priority) { | 355 JobPriority priority) { |
| 358 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 356 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 359 | 357 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 } | 532 } |
| 535 | 533 |
| 536 TimeDelta run_delay = | 534 TimeDelta run_delay = |
| 537 pending_nudge_job_->scheduled_start() - TimeTicks::Now(); | 535 pending_nudge_job_->scheduled_start() - TimeTicks::Now(); |
| 538 if (run_delay < TimeDelta::FromMilliseconds(0)) | 536 if (run_delay < TimeDelta::FromMilliseconds(0)) |
| 539 run_delay = TimeDelta::FromMilliseconds(0); | 537 run_delay = TimeDelta::FromMilliseconds(0); |
| 540 SDVLOG_LOC(nudge_location, 2) | 538 SDVLOG_LOC(nudge_location, 2) |
| 541 << "Scheduling a nudge with " | 539 << "Scheduling a nudge with " |
| 542 << run_delay.InMilliseconds() << " ms delay"; | 540 << run_delay.InMilliseconds() << " ms delay"; |
| 543 | 541 |
| 544 PostDelayedTask( | 542 if (started_) { |
| 545 nudge_location, | 543 pending_wakeup_timer_.Start( |
| 546 "DoSyncSessionJob", | 544 nudge_location, |
| 547 base::Bind(base::IgnoreResult(&SyncSchedulerImpl::DoNudgeSyncSessionJob), | 545 run_delay, |
| 548 weak_ptr_factory_.GetWeakPtr(), | 546 base::Bind(&SyncSchedulerImpl::DoNudgeSyncSessionJob, |
| 549 NORMAL_PRIORITY), | 547 weak_ptr_factory_.GetWeakPtr(), |
| 550 run_delay); | 548 NORMAL_PRIORITY)); |
| 549 } | |
| 551 } | 550 } |
| 552 | 551 |
| 553 const char* SyncSchedulerImpl::GetModeString(SyncScheduler::Mode mode) { | 552 const char* SyncSchedulerImpl::GetModeString(SyncScheduler::Mode mode) { |
| 554 switch (mode) { | 553 switch (mode) { |
| 555 ENUM_CASE(CONFIGURATION_MODE); | 554 ENUM_CASE(CONFIGURATION_MODE); |
| 556 ENUM_CASE(NORMAL_MODE); | 555 ENUM_CASE(NORMAL_MODE); |
| 557 } | 556 } |
| 558 return ""; | 557 return ""; |
| 559 } | 558 } |
| 560 | 559 |
| 561 const char* SyncSchedulerImpl::GetDecisionString( | 560 const char* SyncSchedulerImpl::GetDecisionString( |
| 562 SyncSchedulerImpl::JobProcessDecision mode) { | 561 SyncSchedulerImpl::JobProcessDecision mode) { |
| 563 switch (mode) { | 562 switch (mode) { |
| 564 ENUM_CASE(CONTINUE); | 563 ENUM_CASE(CONTINUE); |
| 565 ENUM_CASE(SAVE); | 564 ENUM_CASE(SAVE); |
| 566 ENUM_CASE(DROP); | 565 ENUM_CASE(DROP); |
| 567 } | 566 } |
| 568 return ""; | 567 return ""; |
| 569 } | 568 } |
| 570 | 569 |
| 571 void SyncSchedulerImpl::PostDelayedTask( | |
| 572 const tracked_objects::Location& from_here, | |
| 573 const char* name, const base::Closure& task, base::TimeDelta delay) { | |
| 574 SDVLOG_LOC(from_here, 3) << "Posting " << name << " task with " | |
| 575 << delay.InMilliseconds() << " ms delay"; | |
| 576 DCHECK_EQ(MessageLoop::current(), sync_loop_); | |
| 577 if (!started_) { | |
| 578 SDVLOG(1) << "Not posting task as scheduler is stopped."; | |
| 579 return; | |
| 580 } | |
| 581 // This cancels the previous task, if one existed. | |
| 582 pending_wakeup_event_.Reset(task); | |
| 583 sync_loop_->PostDelayedTask(from_here, | |
| 584 pending_wakeup_event_.callback(), | |
| 585 delay); | |
| 586 } | |
| 587 | |
| 588 bool SyncSchedulerImpl::DoSyncSessionJobImpl(scoped_ptr<SyncSessionJob> job, | 570 bool SyncSchedulerImpl::DoSyncSessionJobImpl(scoped_ptr<SyncSessionJob> job, |
| 589 JobPriority priority) { | 571 JobPriority priority) { |
| 590 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 572 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 591 | 573 |
| 592 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); | 574 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); |
| 593 JobProcessDecision decision = DecideOnJob(*job, priority); | 575 JobProcessDecision decision = DecideOnJob(*job, priority); |
| 594 SDVLOG(2) << "Should run " | 576 SDVLOG(2) << "Should run " |
| 595 << SyncSessionJob::GetPurposeString(job->purpose()) | 577 << SyncSessionJob::GetPurposeString(job->purpose()) |
| 596 << " in mode " << GetModeString(mode_) | 578 << " in mode " << GetModeString(mode_) |
| 597 << " with source " << job->source_info().updates_source | 579 << " with source " << job->source_info().updates_source |
| 598 << ": " << GetDecisionString(decision); | 580 << ": " << GetDecisionString(decision); |
| 599 if (decision != CONTINUE) { | 581 if (decision != CONTINUE) { |
| 600 if (decision == SAVE) { | 582 if (decision == SAVE) { |
| 601 if (job->purpose() == SyncSessionJob::CONFIGURATION) { | 583 if (job->purpose() == SyncSessionJob::CONFIGURATION) { |
| 602 pending_configure_job_ = job.Pass(); | 584 pending_configure_job_ = job.Pass(); |
| 603 | |
| 604 // It's very unlikely, but possible, that the WaitInterval's wakeup task | |
| 605 // isn't actually active at this point. Sometimes the WaitInterval gets | |
| 606 // preempted by a nudge-while-in-backoff. We can't just assume that | |
| 607 // there's a task waiting to wake us up once the WaitInterval expires; | |
| 608 // we need to ensure it by rescheduling the WaitInterval (while taking | |
| 609 // into account any time already spent waiting, of course). | |
| 610 ResumeWaiting(); | |
| 611 } else { | 585 } else { |
| 612 pending_nudge_job_ = job.Pass(); | 586 pending_nudge_job_ = job.Pass(); |
| 613 } | 587 } |
| 614 } else { | 588 } else { |
| 615 DCHECK_EQ(decision, DROP); | 589 DCHECK_EQ(decision, DROP); |
| 616 } | 590 } |
| 617 return false; | 591 return false; |
| 618 } | 592 } |
| 619 | 593 |
| 620 DVLOG(2) << "Creating sync session with routes " | 594 DVLOG(2) << "Creating sync session with routes " |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 645 RestartWaiting(); | 619 RestartWaiting(); |
| 646 return success; | 620 return success; |
| 647 } | 621 } |
| 648 | 622 |
| 649 if (!success) | 623 if (!success) |
| 650 ScheduleNextSync(job.Pass(), &session); | 624 ScheduleNextSync(job.Pass(), &session); |
| 651 | 625 |
| 652 return success; | 626 return success; |
| 653 } | 627 } |
| 654 | 628 |
| 655 bool SyncSchedulerImpl::DoNudgeSyncSessionJob(JobPriority priority) { | 629 void SyncSchedulerImpl::DoNudgeSyncSessionJob(JobPriority priority) { |
| 656 return DoSyncSessionJobImpl(pending_nudge_job_.Pass(), priority); | 630 DoSyncSessionJobImpl(pending_nudge_job_.Pass(), priority); |
| 657 } | 631 } |
| 658 | 632 |
| 659 bool SyncSchedulerImpl::DoConfigurationSyncSessionJob(JobPriority priority) { | 633 bool SyncSchedulerImpl::DoConfigurationSyncSessionJob(JobPriority priority) { |
| 660 return DoSyncSessionJobImpl(pending_configure_job_.Pass(), priority); | 634 return DoSyncSessionJobImpl(pending_configure_job_.Pass(), priority); |
| 661 } | 635 } |
| 662 | 636 |
| 663 bool SyncSchedulerImpl::ShouldPoll() { | 637 bool SyncSchedulerImpl::ShouldPoll() { |
| 664 if (wait_interval_.get()) { | 638 if (wait_interval_.get()) { |
| 665 SDVLOG(2) << "Not running poll in wait interval."; | 639 SDVLOG(2) << "Not running poll in wait interval."; |
| 666 return false; | 640 return false; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 749 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 776 DCHECK(finished_job->purpose() == SyncSessionJob::CONFIGURATION | 750 DCHECK(finished_job->purpose() == SyncSessionJob::CONFIGURATION |
| 777 || finished_job->purpose() == SyncSessionJob::NUDGE); | 751 || finished_job->purpose() == SyncSessionJob::NUDGE); |
| 778 | 752 |
| 779 // TODO(rlarocque): There's no reason why we should blindly backoff and retry | 753 // TODO(rlarocque): There's no reason why we should blindly backoff and retry |
| 780 // if we don't succeed. Some types of errors are not likely to disappear on | 754 // if we don't succeed. Some types of errors are not likely to disappear on |
| 781 // their own. With the return values now available in the old_job.session, | 755 // their own. With the return values now available in the old_job.session, |
| 782 // we should be able to detect such errors and only retry when we detect | 756 // we should be able to detect such errors and only retry when we detect |
| 783 // transient errors. | 757 // transient errors. |
| 784 | 758 |
| 785 if (IsBackingOff() && wait_interval_->timer.IsRunning() && | 759 SDVLOG(2) << "SyncShare job failed; will start or update backoff"; |
| 786 mode_ == NORMAL_MODE) { | 760 HandleContinuationError(finished_job.Pass(), session); |
| 787 // When in normal mode, we allow up to one nudge per backoff interval. It | |
| 788 // appears that this was our nudge for this interval, and it failed. | |
| 789 // | |
| 790 // Note: This does not prevent us from running canary jobs. For example, | |
| 791 // an IP address change might still result in another nudge being executed | |
| 792 // during this backoff interval. | |
| 793 SDVLOG(2) << "A nudge during backoff failed, creating new pending nudge."; | |
| 794 DCHECK_EQ(SyncSessionJob::NUDGE, finished_job->purpose()); | |
| 795 DCHECK(!wait_interval_->had_nudge); | |
| 796 | |
| 797 wait_interval_->had_nudge = true; | |
| 798 DCHECK(!pending_nudge_job_); | |
| 799 | |
| 800 pending_nudge_job_ = finished_job.Pass(); | |
| 801 RestartWaiting(); | |
| 802 } else { | |
| 803 // Either this is the first failure or a consecutive failure after our | |
| 804 // backoff timer expired. We handle it the same way in either case. | |
| 805 SDVLOG(2) << "Non-'backoff nudge' SyncShare job failed"; | |
| 806 HandleContinuationError(finished_job.Pass(), session); | |
| 807 } | |
| 808 } | 761 } |
| 809 | 762 |
| 810 void SyncSchedulerImpl::AdjustPolling(const SyncSessionJob* old_job) { | 763 void SyncSchedulerImpl::AdjustPolling(const SyncSessionJob* old_job) { |
| 811 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 764 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 812 | 765 |
| 813 TimeDelta poll = (!session_context_->notifications_enabled()) ? | 766 TimeDelta poll = (!session_context_->notifications_enabled()) ? |
| 814 syncer_short_poll_interval_seconds_ : | 767 syncer_short_poll_interval_seconds_ : |
| 815 syncer_long_poll_interval_seconds_; | 768 syncer_long_poll_interval_seconds_; |
| 816 bool rate_changed = !poll_timer_.IsRunning() || | 769 bool rate_changed = !poll_timer_.IsRunning() || |
| 817 poll != poll_timer_.GetCurrentDelay(); | 770 poll != poll_timer_.GetCurrentDelay(); |
| 818 | 771 |
| 819 if (old_job && old_job->purpose() != SyncSessionJob::POLL && !rate_changed) | 772 if (old_job && old_job->purpose() != SyncSessionJob::POLL && !rate_changed) |
| 820 poll_timer_.Reset(); | 773 poll_timer_.Reset(); |
| 821 | 774 |
| 822 if (!rate_changed) | 775 if (!rate_changed) |
| 823 return; | 776 return; |
| 824 | 777 |
| 825 // Adjust poll rate. | 778 // Adjust poll rate. |
| 826 poll_timer_.Stop(); | 779 poll_timer_.Stop(); |
| 827 poll_timer_.Start(FROM_HERE, poll, this, | 780 poll_timer_.Start(FROM_HERE, poll, this, |
| 828 &SyncSchedulerImpl::PollTimerCallback); | 781 &SyncSchedulerImpl::PollTimerCallback); |
| 829 } | 782 } |
| 830 | 783 |
| 831 void SyncSchedulerImpl::ResumeWaiting() { | |
| 832 TimeDelta length = | |
| 833 wait_interval_->timer.desired_run_time() - TimeTicks::Now(); | |
| 834 wait_interval_->length = length < TimeDelta::FromSeconds(0) ? | |
| 835 TimeDelta::FromSeconds(0) : length; | |
| 836 RestartWaiting(); | |
| 837 } | |
| 838 | |
| 839 void SyncSchedulerImpl::RestartWaiting() { | 784 void SyncSchedulerImpl::RestartWaiting() { |
| 840 CHECK(wait_interval_.get()); | 785 CHECK(wait_interval_.get()); |
| 841 wait_interval_->timer.Stop(); | |
| 842 DCHECK(wait_interval_->length >= TimeDelta::FromSeconds(0)); | 786 DCHECK(wait_interval_->length >= TimeDelta::FromSeconds(0)); |
| 843 if (wait_interval_->mode == WaitInterval::THROTTLED) { | 787 if (wait_interval_->mode == WaitInterval::THROTTLED) { |
| 844 pending_wakeup_event_.Reset(base::Bind(&SyncSchedulerImpl::Unthrottle, | 788 pending_wakeup_timer_.Start( |
| 845 weak_ptr_factory_.GetWeakPtr())); | 789 FROM_HERE, |
| 846 | 790 wait_interval_->length, |
| 791 base::Bind(&SyncSchedulerImpl::Unthrottle, | |
| 792 weak_ptr_factory_.GetWeakPtr())); | |
| 847 } else { | 793 } else { |
| 848 pending_wakeup_event_.Reset(base::Bind(&SyncSchedulerImpl::TryCanaryJob, | 794 pending_wakeup_timer_.Start( |
| 849 weak_ptr_factory_.GetWeakPtr())); | 795 FROM_HERE, |
| 796 wait_interval_->length, | |
| 797 base::Bind(&SyncSchedulerImpl::TryCanaryJob, | |
| 798 weak_ptr_factory_.GetWeakPtr())); | |
| 850 } | 799 } |
| 851 wait_interval_->timer.Start(FROM_HERE, wait_interval_->length, | |
| 852 pending_wakeup_event_.callback()); | |
| 853 } | 800 } |
| 854 | 801 |
| 855 void SyncSchedulerImpl::HandleContinuationError( | 802 void SyncSchedulerImpl::HandleContinuationError( |
| 856 scoped_ptr<SyncSessionJob> old_job, | 803 scoped_ptr<SyncSessionJob> old_job, |
| 857 SyncSession* session) { | 804 SyncSession* session) { |
| 858 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 805 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 859 | 806 |
| 860 TimeDelta length = delay_provider_->GetDelay( | 807 TimeDelta length = delay_provider_->GetDelay( |
| 861 IsBackingOff() ? wait_interval_->length : | 808 IsBackingOff() ? wait_interval_->length : |
| 862 delay_provider_->GetInitialDelay( | 809 delay_provider_->GetInitialDelay( |
| 863 session->status_controller().model_neutral_state())); | 810 session->status_controller().model_neutral_state())); |
| 864 | 811 |
| 865 SDVLOG(2) << "In handle continuation error with " | 812 SDVLOG(2) << "In handle continuation error with " |
| 866 << SyncSessionJob::GetPurposeString(old_job->purpose()) | 813 << SyncSessionJob::GetPurposeString(old_job->purpose()) |
| 867 << " job. The time delta(ms) is " | 814 << " job. The time delta(ms) is " |
| 868 << length.InMilliseconds(); | 815 << length.InMilliseconds(); |
| 869 | 816 |
| 870 // This will reset the had_nudge variable as well. | |
| 871 wait_interval_.reset(new WaitInterval(WaitInterval::EXPONENTIAL_BACKOFF, | 817 wait_interval_.reset(new WaitInterval(WaitInterval::EXPONENTIAL_BACKOFF, |
| 872 length)); | 818 length)); |
| 873 NotifyRetryTime(base::Time::Now() + length); | 819 NotifyRetryTime(base::Time::Now() + length); |
| 874 old_job->set_scheduled_start(TimeTicks::Now() + length); | 820 old_job->set_scheduled_start(TimeTicks::Now() + length); |
| 875 if (old_job->purpose() == SyncSessionJob::CONFIGURATION) { | 821 if (old_job->purpose() == SyncSessionJob::CONFIGURATION) { |
| 876 SDVLOG(2) << "Configuration did not succeed, scheduling retry."; | 822 SDVLOG(2) << "Configuration did not succeed, scheduling retry."; |
| 877 // Config params should always get set. | 823 // Config params should always get set. |
| 878 DCHECK(!old_job->config_params().ready_task.is_null()); | 824 DCHECK(!old_job->config_params().ready_task.is_null()); |
| 879 DCHECK(!pending_configure_job_); | 825 DCHECK(!pending_configure_job_); |
| 880 pending_configure_job_ = old_job.Pass(); | 826 pending_configure_job_ = old_job.Pass(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 899 | 845 |
| 900 void SyncSchedulerImpl::StopImpl(const base::Closure& callback) { | 846 void SyncSchedulerImpl::StopImpl(const base::Closure& callback) { |
| 901 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 847 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 902 SDVLOG(2) << "StopImpl called"; | 848 SDVLOG(2) << "StopImpl called"; |
| 903 | 849 |
| 904 // Kill any in-flight method calls. | 850 // Kill any in-flight method calls. |
| 905 weak_ptr_factory_.InvalidateWeakPtrs(); | 851 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 906 wait_interval_.reset(); | 852 wait_interval_.reset(); |
| 907 NotifyRetryTime(base::Time()); | 853 NotifyRetryTime(base::Time()); |
| 908 poll_timer_.Stop(); | 854 poll_timer_.Stop(); |
| 909 pending_wakeup_event_.Cancel(); | 855 pending_wakeup_timer_.Stop(); |
| 910 pending_nudge_job_.reset(); | 856 pending_nudge_job_.reset(); |
| 911 pending_configure_job_.reset(); | 857 pending_configure_job_.reset(); |
| 912 if (started_) { | 858 if (started_) { |
| 913 started_ = false; | 859 started_ = false; |
| 914 } | 860 } |
| 915 if (!callback.is_null()) | 861 if (!callback.is_null()) |
| 916 callback.Run(); | 862 callback.Run(); |
| 917 } | 863 } |
| 918 | 864 |
| 919 // This is the only place where we invoke DoSyncSessionJob with canary | 865 // This is the only place where we invoke DoSyncSessionJob with canary |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1053 | 999 |
| 1054 #undef SDVLOG_LOC | 1000 #undef SDVLOG_LOC |
| 1055 | 1001 |
| 1056 #undef SDVLOG | 1002 #undef SDVLOG |
| 1057 | 1003 |
| 1058 #undef SLOG | 1004 #undef SLOG |
| 1059 | 1005 |
| 1060 #undef ENUM_CASE | 1006 #undef ENUM_CASE |
| 1061 | 1007 |
| 1062 } // namespace syncer | 1008 } // namespace syncer |
| OLD | NEW |