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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 } | 336 } |
337 | 337 |
338 return true; | 338 return true; |
339 } | 339 } |
340 | 340 |
341 SyncSchedulerImpl::JobProcessDecision | 341 SyncSchedulerImpl::JobProcessDecision |
342 SyncSchedulerImpl::DecideWhileInWaitInterval(const SyncSessionJob& job, | 342 SyncSchedulerImpl::DecideWhileInWaitInterval(const SyncSessionJob& job, |
343 JobPriority priority) { | 343 JobPriority priority) { |
344 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 344 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
345 DCHECK(wait_interval_.get()); | 345 DCHECK(wait_interval_.get()); |
346 DCHECK_NE(job.purpose(), SyncSessionJob::POLL); | |
346 | 347 |
347 SDVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " | 348 SDVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " |
348 << WaitInterval::GetModeString(wait_interval_->mode) | 349 << WaitInterval::GetModeString(wait_interval_->mode) |
349 << (wait_interval_->had_nudge ? " (had nudge)" : "") | 350 << (wait_interval_->had_nudge ? " (had nudge)" : "") |
350 << ((priority == CANARY_PRIORITY) ? " (canary)" : ""); | 351 << ((priority == CANARY_PRIORITY) ? " (canary)" : ""); |
351 | 352 |
352 if (job.purpose() == SyncSessionJob::POLL) | |
353 return DROP; | |
354 | |
355 // If we save a job while in a WaitInterval, there is a well-defined moment | 353 // If we save a job while in a WaitInterval, there is a well-defined moment |
356 // in time in the future when it makes sense for that SAVE-worthy job to try | 354 // in time in the future when it makes sense for that SAVE-worthy job to try |
357 // running again -- the end of the WaitInterval. | 355 // running again -- the end of the WaitInterval. |
358 DCHECK(job.purpose() == SyncSessionJob::NUDGE || | 356 DCHECK(job.purpose() == SyncSessionJob::NUDGE || |
359 job.purpose() == SyncSessionJob::CONFIGURATION); | 357 job.purpose() == SyncSessionJob::CONFIGURATION); |
360 | 358 |
361 // If throttled, there's a clock ticking to unthrottle. We want to get | 359 // If throttled, there's a clock ticking to unthrottle. We want to get |
362 // on the same train. | 360 // on the same train. |
363 if (wait_interval_->mode == WaitInterval::THROTTLED) | 361 if (wait_interval_->mode == WaitInterval::THROTTLED) |
364 return SAVE; | 362 return SAVE; |
(...skipping 11 matching lines...) Expand all Loading... | |
376 return CONTINUE; | 374 return CONTINUE; |
377 } | 375 } |
378 return (priority == CANARY_PRIORITY) ? CONTINUE : SAVE; | 376 return (priority == CANARY_PRIORITY) ? CONTINUE : SAVE; |
379 } | 377 } |
380 | 378 |
381 SyncSchedulerImpl::JobProcessDecision SyncSchedulerImpl::DecideOnJob( | 379 SyncSchedulerImpl::JobProcessDecision SyncSchedulerImpl::DecideOnJob( |
382 const SyncSessionJob& job, | 380 const SyncSessionJob& job, |
383 JobPriority priority) { | 381 JobPriority priority) { |
384 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 382 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
385 | 383 |
384 // POLL jobs do not call this function. | |
385 DCHECK(job.purpose() == SyncSessionJob::NUDGE || | |
386 job.purpose() == SyncSessionJob::CONFIGURATION); | |
387 | |
386 // See if our type is throttled. | 388 // See if our type is throttled. |
387 ModelTypeSet throttled_types = | 389 ModelTypeSet throttled_types = |
388 session_context_->throttled_data_type_tracker()->GetThrottledTypes(); | 390 session_context_->throttled_data_type_tracker()->GetThrottledTypes(); |
389 if (job.purpose() == SyncSessionJob::NUDGE && | 391 if (job.purpose() == SyncSessionJob::NUDGE && |
390 job.session()->source().updates_source == GetUpdatesCallerInfo::LOCAL) { | 392 job.session()->source().updates_source == GetUpdatesCallerInfo::LOCAL) { |
391 ModelTypeSet requested_types; | 393 ModelTypeSet requested_types; |
392 for (ModelTypeInvalidationMap::const_iterator i = | 394 for (ModelTypeInvalidationMap::const_iterator i = |
393 job.session()->source().types.begin(); | 395 job.session()->source().types.begin(); |
394 i != job.session()->source().types.end(); | 396 i != job.session()->source().types.end(); |
395 ++i) { | 397 ++i) { |
396 requested_types.Put(i->first); | 398 requested_types.Put(i->first); |
397 } | 399 } |
398 | 400 |
399 // If all types are throttled, do not CONTINUE. Today, we don't treat | 401 // If all types are throttled, do not CONTINUE. Today, we don't treat |
400 // a per-datatype "unthrottle" event as something that should force a | 402 // a per-datatype "unthrottle" event as something that should force a |
401 // canary job. For this reason, there's no good time to reschedule this job | 403 // canary job. For this reason, there's no good time to reschedule this job |
402 // to run -- we'll lazily wait for an independent event to trigger a sync. | 404 // to run -- we'll lazily wait for an independent event to trigger a sync. |
403 // Note that there may already be such an event if we're in a WaitInterval, | 405 // Note that there may already be such an event if we're in a WaitInterval, |
404 // so we can retry it then. | 406 // so we can retry it then. |
405 if (!requested_types.Empty() && throttled_types.HasAll(requested_types)) | 407 if (!requested_types.Empty() && throttled_types.HasAll(requested_types)) |
406 return DROP; // TODO(tim): Don't drop. http://crbug.com/177659 | 408 return DROP; // TODO(tim): Don't drop. http://crbug.com/177659 |
407 } | 409 } |
408 | 410 |
409 if (wait_interval_.get()) | 411 if (wait_interval_.get()) |
410 return DecideWhileInWaitInterval(job, priority); | 412 return DecideWhileInWaitInterval(job, priority); |
411 | 413 |
412 if (mode_ == CONFIGURATION_MODE) { | 414 if (mode_ == CONFIGURATION_MODE) { |
413 if (job.purpose() == SyncSessionJob::NUDGE) | 415 if (job.purpose() == SyncSessionJob::NUDGE) |
414 return SAVE; // Running requires a mode switch. | 416 return SAVE; // Running requires a mode switch. |
415 else if (job.purpose() == SyncSessionJob::CONFIGURATION) | 417 else // job.purpose() == SyncSessionJob::CONFIGURATION |
tim (not reviewing)
2013/03/18 22:57:40
I think you mean to delete this.
| |
416 return CONTINUE; | 418 return CONTINUE; |
417 else | |
418 return DROP; | |
419 } | 419 } |
420 | 420 |
421 // We are in normal mode. | 421 // We are in normal mode. |
422 DCHECK_EQ(mode_, NORMAL_MODE); | 422 DCHECK_EQ(mode_, NORMAL_MODE); |
423 DCHECK_NE(job.purpose(), SyncSessionJob::CONFIGURATION); | 423 DCHECK_NE(job.purpose(), SyncSessionJob::CONFIGURATION); |
424 | 424 |
425 // Note about some subtle scheduling semantics. | 425 // Note about some subtle scheduling semantics. |
426 // | 426 // |
427 // It's possible at this point that |job| is known to be unnecessary, and | 427 // It's possible at this point that |job| is known to be unnecessary, and |
428 // dropping it would be perfectly safe and correct. Consider | 428 // dropping it would be perfectly safe and correct. Consider |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 SDVLOG_LOC(from_here, 3) << "Posting " << name << " task with " | 672 SDVLOG_LOC(from_here, 3) << "Posting " << name << " task with " |
673 << delay.InMilliseconds() << " ms delay"; | 673 << delay.InMilliseconds() << " ms delay"; |
674 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 674 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
675 if (!started_) { | 675 if (!started_) { |
676 SDVLOG(1) << "Not posting task as scheduler is stopped."; | 676 SDVLOG(1) << "Not posting task as scheduler is stopped."; |
677 return; | 677 return; |
678 } | 678 } |
679 sync_loop_->PostDelayedTask(from_here, task, delay); | 679 sync_loop_->PostDelayedTask(from_here, task, delay); |
680 } | 680 } |
681 | 681 |
682 void SyncSchedulerImpl::ScheduleSyncSessionJob( | 682 void SyncSchedulerImpl::ScheduleSyncSessionJob( |
tim (not reviewing)
2013/03/18 22:57:40
How about we call this PostNudgeJob, or something,
rlarocque
2013/03/19 00:15:03
I'd like to merge this into ScheduleNudgeImpl. If
tim (not reviewing)
2013/03/19 21:50:02
OK, lets merge it there. Make sure you update comm
rlarocque
2013/03/19 22:46:42
Done. The merge wasn't entirely straightforward.
| |
683 const tracked_objects::Location& loc, | 683 const tracked_objects::Location& loc, |
684 scoped_ptr<SyncSessionJob> job) { | 684 scoped_ptr<SyncSessionJob> job) { |
685 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 685 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
686 DCHECK_EQ(job->purpose(), SyncSessionJob::NUDGE); | |
686 if (no_scheduling_allowed_) { | 687 if (no_scheduling_allowed_) { |
687 NOTREACHED() << "Illegal to schedule job while session in progress."; | 688 NOTREACHED() << "Illegal to schedule job while session in progress."; |
688 return; | 689 return; |
689 } | 690 } |
690 | 691 |
691 TimeDelta delay = job->scheduled_start() - TimeTicks::Now(); | 692 TimeDelta delay = job->scheduled_start() - TimeTicks::Now(); |
692 if (delay < TimeDelta::FromMilliseconds(0)) | 693 if (delay < TimeDelta::FromMilliseconds(0)) |
693 delay = TimeDelta::FromMilliseconds(0); | 694 delay = TimeDelta::FromMilliseconds(0); |
694 SDVLOG_LOC(loc, 2) | 695 SDVLOG_LOC(loc, 2) |
695 << "In ScheduleSyncSessionJob with " | 696 << "In ScheduleSyncSessionJob with " |
696 << SyncSessionJob::GetPurposeString(job->purpose()) | 697 << SyncSessionJob::GetPurposeString(job->purpose()) |
697 << " job and " << delay.InMilliseconds() << " ms delay"; | 698 << " job and " << delay.InMilliseconds() << " ms delay"; |
698 | 699 |
699 DCHECK(job->purpose() == SyncSessionJob::NUDGE || | 700 SDVLOG_LOC(loc, 2) << "Resetting pending_nudge to "; |
700 job->purpose() == SyncSessionJob::POLL); | 701 DCHECK(!pending_nudge_ || pending_nudge_->session() == |
701 if (job->purpose() == SyncSessionJob::NUDGE) { | 702 job->session()); |
702 SDVLOG_LOC(loc, 2) << "Resetting pending_nudge to "; | 703 pending_nudge_ = job.get(); |
703 DCHECK(!pending_nudge_ || pending_nudge_->session() == | |
704 job->session()); | |
705 pending_nudge_ = job.get(); | |
706 } | |
707 | 704 |
708 PostDelayedTask(loc, "DoSyncSessionJob", | 705 PostDelayedTask(loc, "DoSyncSessionJob", |
709 base::Bind(base::IgnoreResult(&SyncSchedulerImpl::DoSyncSessionJob), | 706 base::Bind(base::IgnoreResult(&SyncSchedulerImpl::DoSyncSessionJob), |
710 weak_ptr_factory_.GetWeakPtr(), | 707 weak_ptr_factory_.GetWeakPtr(), |
711 base::Passed(&job), | 708 base::Passed(&job), |
712 NORMAL_PRIORITY), | 709 NORMAL_PRIORITY), |
713 delay); | 710 delay); |
714 } | 711 } |
715 | 712 |
716 bool SyncSchedulerImpl::DoSyncSessionJob(scoped_ptr<SyncSessionJob> job, | 713 bool SyncSchedulerImpl::DoSyncSessionJob(scoped_ptr<SyncSessionJob> job, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 return false; | 746 return false; |
750 } | 747 } |
751 | 748 |
752 SDVLOG(2) << "Calling SyncShare with " | 749 SDVLOG(2) << "Calling SyncShare with " |
753 << SyncSessionJob::GetPurposeString(job->purpose()) << " job"; | 750 << SyncSessionJob::GetPurposeString(job->purpose()) << " job"; |
754 bool premature_exit = !syncer_->SyncShare(job->mutable_session(), | 751 bool premature_exit = !syncer_->SyncShare(job->mutable_session(), |
755 job->start_step(), | 752 job->start_step(), |
756 job->end_step()); | 753 job->end_step()); |
757 SDVLOG(2) << "Done SyncShare, returned: " << premature_exit; | 754 SDVLOG(2) << "Done SyncShare, returned: " << premature_exit; |
758 | 755 |
759 return FinishSyncSessionJob(job.Pass(), premature_exit); | 756 bool success = FinishSyncSessionJob(job.get(), premature_exit); |
rlarocque
2013/03/18 22:02:18
One of the goals of this patch is to take all the
tim (not reviewing)
2013/03/18 22:57:40
Please audit all the comments that reference DoSyn
| |
757 | |
758 if (IsSyncingCurrentlySilenced()) { | |
759 SDVLOG(2) << "We are currently throttled; scheduling Unthrottle."; | |
760 // If we're here, it's because |job| was silenced until a server specified | |
761 // time. (Note, it had to be |job|, because DecideOnJob would not permit | |
762 // any job through while in WaitInterval::THROTTLED). | |
763 scoped_ptr<SyncSessionJob> clone = job->Clone(); | |
764 if (clone->purpose() == SyncSessionJob::NUDGE) | |
765 pending_nudge_ = clone.get(); | |
766 else if (clone->purpose() == SyncSessionJob::CONFIGURATION) | |
767 wait_interval_->pending_configure_job = clone.get(); | |
768 else | |
769 NOTREACHED(); | |
770 | |
771 RestartWaiting(clone.Pass()); | |
772 return success; | |
773 } | |
774 | |
775 if (!success) { | |
tim (not reviewing)
2013/03/18 22:57:40
nit - please make { } usage consistent for single
rlarocque
2013/03/19 00:15:03
I think it's been inconsistent for a while. For e
| |
776 ScheduleNextSync(job.Pass()); | |
777 } | |
778 | |
779 return success; | |
780 } | |
781 | |
782 void SyncSchedulerImpl::DoPollSyncSessionJob(scoped_ptr<SyncSessionJob> job) { | |
783 DCHECK_EQ(job->purpose(), SyncSessionJob::POLL); | |
784 | |
785 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); | |
786 | |
787 if (wait_interval_.get()) { | |
rlarocque
2013/03/18 22:02:18
The if statements on lines 787-800 are intended to
tim (not reviewing)
2013/03/18 22:57:40
I know this may seem pedantic, but I'd like to try
rlarocque
2013/03/19 00:15:03
I see your point. I agree that we want to keep al
| |
788 SDVLOG(2) << "Dropping POLL job in wait interval."; | |
789 return; | |
790 } | |
791 | |
792 if (mode_ == CONFIGURATION_MODE) { | |
793 SDVLOG(2) << "Dropping POLL job in configuration mode."; | |
794 return; | |
795 } | |
796 | |
797 if (session_context_->connection_manager()->HasInvalidAuthToken()) { | |
798 SDVLOG(2) << "Dropping POLL job because auth token is invalid."; | |
799 return; | |
800 } | |
801 | |
802 SDVLOG(2) << "Calling SyncShare with " | |
803 << SyncSessionJob::GetPurposeString(job->purpose()) << " job"; | |
804 bool premature_exit = !syncer_->SyncShare(job->mutable_session(), | |
805 job->start_step(), | |
806 job->end_step()); | |
807 SDVLOG(2) << "Done SyncShare, returned: " << premature_exit; | |
808 | |
809 FinishSyncSessionJob(job.get(), premature_exit); | |
810 | |
811 if (IsSyncingCurrentlySilenced()) { | |
812 RestartWaiting(scoped_ptr<SyncSessionJob>()); | |
tim (not reviewing)
2013/03/18 22:57:40
Comment that we send a NULL job here because a POL
rlarocque
2013/03/19 00:15:03
Will do.
| |
813 } | |
760 } | 814 } |
761 | 815 |
762 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { | 816 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { |
763 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 817 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
764 | 818 |
765 // We are interested in recording time between local nudges for datatypes. | 819 // We are interested in recording time between local nudges for datatypes. |
766 // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. | 820 // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. |
767 if (info.updates_source != GetUpdatesCallerInfo::LOCAL) | 821 if (info.updates_source != GetUpdatesCallerInfo::LOCAL) |
768 return; | 822 return; |
769 | 823 |
770 base::TimeTicks now = TimeTicks::Now(); | 824 base::TimeTicks now = TimeTicks::Now(); |
771 // Update timing information for how often datatypes are triggering nudges. | 825 // Update timing information for how often datatypes are triggering nudges. |
772 for (ModelTypeInvalidationMap::const_iterator iter = info.types.begin(); | 826 for (ModelTypeInvalidationMap::const_iterator iter = info.types.begin(); |
773 iter != info.types.end(); | 827 iter != info.types.end(); |
774 ++iter) { | 828 ++iter) { |
775 base::TimeTicks previous = last_local_nudges_by_model_type_[iter->first]; | 829 base::TimeTicks previous = last_local_nudges_by_model_type_[iter->first]; |
776 last_local_nudges_by_model_type_[iter->first] = now; | 830 last_local_nudges_by_model_type_[iter->first] = now; |
777 if (previous.is_null()) | 831 if (previous.is_null()) |
778 continue; | 832 continue; |
779 | 833 |
780 #define PER_DATA_TYPE_MACRO(type_str) \ | 834 #define PER_DATA_TYPE_MACRO(type_str) \ |
781 SYNC_FREQ_HISTOGRAM("Sync.Freq" type_str, now - previous); | 835 SYNC_FREQ_HISTOGRAM("Sync.Freq" type_str, now - previous); |
782 SYNC_DATA_TYPE_HISTOGRAM(iter->first); | 836 SYNC_DATA_TYPE_HISTOGRAM(iter->first); |
783 #undef PER_DATA_TYPE_MACRO | 837 #undef PER_DATA_TYPE_MACRO |
784 } | 838 } |
785 } | 839 } |
786 | 840 |
787 bool SyncSchedulerImpl::FinishSyncSessionJob(scoped_ptr<SyncSessionJob> job, | 841 bool SyncSchedulerImpl::FinishSyncSessionJob(SyncSessionJob* job, |
788 bool exited_prematurely) { | 842 bool exited_prematurely) { |
789 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 843 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
790 | 844 |
791 // Let job know that we're through syncing (calling SyncShare) at this point. | 845 // Let job know that we're through syncing (calling SyncShare) at this point. |
792 bool succeeded = false; | 846 bool succeeded = false; |
793 { | 847 { |
794 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); | 848 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); |
795 succeeded = job->Finish(exited_prematurely); | 849 succeeded = job->Finish(exited_prematurely); |
796 } | 850 } |
797 | 851 |
798 SDVLOG(2) << "Updating the next polling time after SyncMain"; | 852 SDVLOG(2) << "Updating the next polling time after SyncMain"; |
799 ScheduleNextSync(job.Pass(), succeeded); | |
800 return succeeded; | |
801 } | |
802 | 853 |
803 void SyncSchedulerImpl::ScheduleNextSync( | 854 AdjustPolling(job); |
804 scoped_ptr<SyncSessionJob> finished_job, bool succeeded) { | |
805 DCHECK_EQ(MessageLoop::current(), sync_loop_); | |
806 | |
807 AdjustPolling(finished_job.get()); | |
808 | 855 |
809 if (succeeded) { | 856 if (succeeded) { |
810 // No job currently supported by the scheduler could succeed without | 857 // No job currently supported by the scheduler could succeed without |
811 // successfully reaching the server. Therefore, if we make it here, it is | 858 // successfully reaching the server. Therefore, if we make it here, it is |
812 // appropriate to reset the backoff interval. | 859 // appropriate to reset the backoff interval. |
813 wait_interval_.reset(); | 860 wait_interval_.reset(); |
814 NotifyRetryTime(base::Time()); | 861 NotifyRetryTime(base::Time()); |
815 SDVLOG(2) << "Job succeeded so not scheduling more jobs"; | 862 SDVLOG(2) << "Job succeeded so not scheduling more jobs"; |
816 return; | 863 return succeeded; |
tim (not reviewing)
2013/03/18 22:57:40
Just fall through?
rlarocque
2013/03/19 00:15:03
Will do.
| |
817 } | 864 } |
818 | 865 |
819 if (IsSyncingCurrentlySilenced()) { | 866 return succeeded; |
820 SDVLOG(2) << "We are currently throttled; scheduling Unthrottle."; | 867 } |
821 // If we're here, it's because |job| was silenced until a server specified | |
822 // time. (Note, it had to be |job|, because DecideOnJob would not permit | |
823 // any job through while in WaitInterval::THROTTLED). | |
824 scoped_ptr<SyncSessionJob> clone = finished_job->Clone(); | |
825 if (clone->purpose() == SyncSessionJob::NUDGE) | |
826 pending_nudge_ = clone.get(); | |
827 else if (clone->purpose() == SyncSessionJob::CONFIGURATION) | |
828 wait_interval_->pending_configure_job = clone.get(); | |
829 else | |
830 clone.reset(); // Unthrottling is enough, no need to force a canary. | |
831 | 868 |
832 RestartWaiting(clone.Pass()); | 869 void SyncSchedulerImpl::ScheduleNextSync( |
833 return; | 870 scoped_ptr<SyncSessionJob> finished_job) { |
834 } | 871 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
835 | 872 DCHECK(finished_job->purpose() == SyncSessionJob::CONFIGURATION |
836 if (finished_job->purpose() == SyncSessionJob::POLL) { | 873 || finished_job->purpose() == SyncSessionJob::NUDGE); |
837 return; // We don't retry POLL jobs. | |
838 } | |
839 | 874 |
840 // TODO(rlarocque): There's no reason why we should blindly backoff and retry | 875 // TODO(rlarocque): There's no reason why we should blindly backoff and retry |
841 // if we don't succeed. Some types of errors are not likely to disappear on | 876 // if we don't succeed. Some types of errors are not likely to disappear on |
842 // their own. With the return values now available in the old_job.session, | 877 // their own. With the return values now available in the old_job.session, |
843 // we should be able to detect such errors and only retry when we detect | 878 // we should be able to detect such errors and only retry when we detect |
844 // transient errors. | 879 // transient errors. |
845 | 880 |
846 if (IsBackingOff() && wait_interval_->timer.IsRunning() && | 881 if (IsBackingOff() && wait_interval_->timer.IsRunning() && |
847 mode_ == NORMAL_MODE) { | 882 mode_ == NORMAL_MODE) { |
848 // When in normal mode, we allow up to one nudge per backoff interval. It | 883 // When in normal mode, we allow up to one nudge per backoff interval. It |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1028 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1063 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1029 ModelSafeRoutingInfo r; | 1064 ModelSafeRoutingInfo r; |
1030 ModelTypeInvalidationMap invalidation_map = | 1065 ModelTypeInvalidationMap invalidation_map = |
1031 ModelSafeRoutingInfoToInvalidationMap(r, std::string()); | 1066 ModelSafeRoutingInfoToInvalidationMap(r, std::string()); |
1032 SyncSourceInfo info(GetUpdatesCallerInfo::PERIODIC, invalidation_map); | 1067 SyncSourceInfo info(GetUpdatesCallerInfo::PERIODIC, invalidation_map); |
1033 scoped_ptr<SyncSession> s(CreateSyncSession(info)); | 1068 scoped_ptr<SyncSession> s(CreateSyncSession(info)); |
1034 scoped_ptr<SyncSessionJob> job(new SyncSessionJob(SyncSessionJob::POLL, | 1069 scoped_ptr<SyncSessionJob> job(new SyncSessionJob(SyncSessionJob::POLL, |
1035 TimeTicks::Now(), | 1070 TimeTicks::Now(), |
1036 s.Pass(), | 1071 s.Pass(), |
1037 ConfigurationParams())); | 1072 ConfigurationParams())); |
1038 ScheduleSyncSessionJob(FROM_HERE, job.Pass()); | 1073 if (no_scheduling_allowed_) { |
1074 NOTREACHED() << "Illegal to schedule job while session in progress."; | |
tim (not reviewing)
2013/03/18 22:57:40
Can you explain why we can't be here, given that t
rlarocque
2013/03/19 00:15:03
The no_scheduling_allowed_ flag is true only when
| |
1075 return; | |
1076 } | |
1077 | |
1078 DoPollSyncSessionJob(job.Pass()); | |
1039 } | 1079 } |
1040 | 1080 |
1041 void SyncSchedulerImpl::Unthrottle(scoped_ptr<SyncSessionJob> to_be_canary) { | 1081 void SyncSchedulerImpl::Unthrottle(scoped_ptr<SyncSessionJob> to_be_canary) { |
1042 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1082 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
1043 DCHECK_EQ(WaitInterval::THROTTLED, wait_interval_->mode); | 1083 DCHECK_EQ(WaitInterval::THROTTLED, wait_interval_->mode); |
1044 DCHECK(!to_be_canary.get() || pending_nudge_ == to_be_canary.get() || | 1084 DCHECK(!to_be_canary.get() || pending_nudge_ == to_be_canary.get() || |
1045 wait_interval_->pending_configure_job == to_be_canary.get()); | 1085 wait_interval_->pending_configure_job == to_be_canary.get()); |
1046 SDVLOG(2) << "Unthrottled " << (to_be_canary.get() ? "with " : "without ") | 1086 SDVLOG(2) << "Unthrottled " << (to_be_canary.get() ? "with " : "without ") |
1047 << "canary."; | 1087 << "canary."; |
1048 | 1088 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1151 | 1191 |
1152 #undef SDVLOG_LOC | 1192 #undef SDVLOG_LOC |
1153 | 1193 |
1154 #undef SDVLOG | 1194 #undef SDVLOG |
1155 | 1195 |
1156 #undef SLOG | 1196 #undef SLOG |
1157 | 1197 |
1158 #undef ENUM_CASE | 1198 #undef ENUM_CASE |
1159 | 1199 |
1160 } // namespace syncer | 1200 } // namespace syncer |
OLD | NEW |