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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 // If not a good time, reschedule a new run. | 767 // If not a good time, reschedule a new run. |
768 if (nudge_tracker_.IsSyncRequired() && CanRunNudgeJobNow(NORMAL_PRIORITY)) | 768 if (nudge_tracker_.IsSyncRequired() && CanRunNudgeJobNow(NORMAL_PRIORITY)) |
769 TrySyncCycleJob(); | 769 TrySyncCycleJob(); |
770 else | 770 else |
771 RestartWaiting(); | 771 RestartWaiting(); |
772 } | 772 } |
773 | 773 |
774 void SyncSchedulerImpl::PerformDelayedNudge() { | 774 void SyncSchedulerImpl::PerformDelayedNudge() { |
775 // Circumstances may have changed since we scheduled this delayed nudge. | 775 // Circumstances may have changed since we scheduled this delayed nudge. |
776 // We must check to see if it's OK to run the job before we do so. | 776 // We must check to see if it's OK to run the job before we do so. |
777 if (CanRunNudgeJobNow(NORMAL_PRIORITY)) | 777 if (CanRunNudgeJobNow(NORMAL_PRIORITY)) { |
778 TrySyncCycleJob(); | 778 TrySyncCycleJob(); |
779 | 779 } else { |
780 // We're not responsible for setting up any retries here. The functions that | 780 // If we set |waiting_interal_| while this PerformDelayedNudge was pending |
781 // first put us into a state that prevents successful sync cycles (eg. global | 781 // callback scheduled to |retry_timer_|, it's possible we didn't re-schedule |
782 // throttling, type throttling, network errors, transient errors) will also | 782 // because this PerformDelayedNudge was going to execute sooner. If that's |
783 // setup the appropriate retry logic (eg. retry after timeout, exponential | 783 // the case, we need to make sure we setup to waiting callback now. |
784 // backoff, retry when the network changes). | 784 RestartWaiting(); |
| 785 } |
785 } | 786 } |
786 | 787 |
787 void SyncSchedulerImpl::ExponentialBackoffRetry() { | 788 void SyncSchedulerImpl::ExponentialBackoffRetry() { |
788 TryCanaryJob(); | 789 TryCanaryJob(); |
789 } | 790 } |
790 | 791 |
791 void SyncSchedulerImpl::NotifyRetryTime(base::Time retry_time) { | 792 void SyncSchedulerImpl::NotifyRetryTime(base::Time retry_time) { |
792 for (auto& observer : *cycle_context_->listeners()) | 793 for (auto& observer : *cycle_context_->listeners()) |
793 observer.OnRetryTimeChanged(retry_time); | 794 observer.OnRetryTimeChanged(retry_time); |
794 } | 795 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 | 966 |
966 #undef SDVLOG_LOC | 967 #undef SDVLOG_LOC |
967 | 968 |
968 #undef SDVLOG | 969 #undef SDVLOG |
969 | 970 |
970 #undef SLOG | 971 #undef SLOG |
971 | 972 |
972 #undef ENUM_CASE | 973 #undef ENUM_CASE |
973 | 974 |
974 } // namespace syncer | 975 } // namespace syncer |
OLD | NEW |