Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/engine/sync_scheduler.h" | 5 #include "chrome/browser/sync/engine/sync_scheduler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 806 return; // Nothing to do. | 806 return; // Nothing to do. |
| 807 } | 807 } |
| 808 | 808 |
| 809 SVLOG(2) << "Updating the next polling time after SyncMain"; | 809 SVLOG(2) << "Updating the next polling time after SyncMain"; |
| 810 ScheduleNextSync(job); | 810 ScheduleNextSync(job); |
| 811 } | 811 } |
| 812 | 812 |
| 813 void SyncScheduler::ScheduleNextSync(const SyncSessionJob& old_job) { | 813 void SyncScheduler::ScheduleNextSync(const SyncSessionJob& old_job) { |
| 814 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 814 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 815 DCHECK(!old_job.session->HasMoreToSync()); | 815 DCHECK(!old_job.session->HasMoreToSync()); |
| 816 // Note: |num_server_changes_remaining| > 0 here implies that we received a | |
| 817 // broken response while trying to download all updates, because the Syncer | |
| 818 // will loop until this value is exhausted. Also, if unsynced_handles exist | |
| 819 // but HasMoreToSync is false, this implies that the Syncer determined no | |
| 820 // forward progress was possible at this time (an error, such as an HTTP | |
| 821 // 500, is likely to have occurred during commit). | |
| 822 int num_server_changes_remaining = | |
| 823 old_job.session->status_controller()->num_server_changes_remaining(); | |
| 824 size_t num_unsynced_handles = | |
| 825 old_job.session->status_controller()->unsynced_handles().size(); | |
| 826 const bool work_to_do = | |
| 827 num_server_changes_remaining > 0 || num_unsynced_handles > 0; | |
| 828 SVLOG(2) << "num server changes remaining: " << num_server_changes_remaining | |
| 829 << ", num unsynced handles: " << num_unsynced_handles | |
| 830 << ", syncer has work to do: " << work_to_do; | |
| 831 | 816 |
| 832 AdjustPolling(&old_job); | 817 AdjustPolling(&old_job); |
| 833 | 818 |
| 834 // TODO(tim): Old impl had special code if notifications disabled. Needed? | 819 // TODO(tim): Old impl had special code if notifications disabled. Needed? |
| 835 if (!work_to_do) { | 820 if (!old_job.session->WasUnableToMakeProgress()) { |
|
tim (not reviewing)
2011/09/20 16:21:57
With the old "SyncerThread" this would have been b
rlarocque
2011/09/20 20:10:03
I don't follow. How does this change affect the w
tim (not reviewing)
2011/09/20 20:32:12
I don't think it does. This was to encourage you t
lipalani1
2011/09/20 23:15:56
When this job is running no new job(nudge) can com
lipalani1
2011/09/20 23:18:09
One more thing, an aside(for Richard): Nudge colla
| |
| 836 // Success implies backoff relief. Note that if this was a | 821 // Success implies backoff relief. Note that if this was a |
| 837 // "one-off" job (i.e. purpose == | 822 // "one-off" job (i.e. purpose == |
| 838 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if | 823 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if |
| 839 // there was work_to_do before it ran this wont have changed, as | 824 // there was work to do before it ran this wont have changed, as |
| 840 // jobs like this don't run a full sync cycle. So we don't need | 825 // jobs like this don't run a full sync cycle. So we don't need |
| 841 // special code here. | 826 // special code here. |
| 842 wait_interval_.reset(); | 827 wait_interval_.reset(); |
| 843 SVLOG(2) << "Job succeeded so not scheduling more jobs"; | 828 SVLOG(2) << "Job succeeded so not scheduling more jobs"; |
| 844 return; | 829 return; |
| 845 } | 830 } |
| 846 | 831 |
| 847 // We are in backoff mode and our time did not run out. That means we had | 832 // We are in backoff mode and our time did not run out. That means we had |
| 848 // a local change, notification from server or a network connection change | 833 // a local change, notification from server or a network connection change |
| 849 // notification. In any case set had_nudge = true so we dont retry next | 834 // notification. In any case set had_nudge = true so we dont retry next |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 860 wait_interval_->had_nudge = true; | 845 wait_interval_->had_nudge = true; |
| 861 // Old job did not finish. So make it the pending job. | 846 // Old job did not finish. So make it the pending job. |
| 862 InitOrCoalescePendingJob(old_job); | 847 InitOrCoalescePendingJob(old_job); |
| 863 // Resume waiting. | 848 // Resume waiting. |
| 864 RestartWaiting(); | 849 RestartWaiting(); |
| 865 } else if (old_job.session->source().updates_source == | 850 } else if (old_job.session->source().updates_source == |
| 866 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION) { | 851 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION) { |
| 867 SVLOG(2) << "Job failed with source continuation"; | 852 SVLOG(2) << "Job failed with source continuation"; |
| 868 // We don't seem to have made forward progress. Start or extend backoff. | 853 // We don't seem to have made forward progress. Start or extend backoff. |
| 869 HandleConsecutiveContinuationError(old_job); | 854 HandleConsecutiveContinuationError(old_job); |
| 870 } else { | 855 } else { |
|
rlarocque
2011/09/20 20:35:21
FYI: This branch is practically unreachable. I'm
| |
| 871 SVLOG(2) << "Failed. Schedule a job with continuation as source"; | 856 SVLOG(2) << "Failed. Schedule a job with continuation as source"; |
| 872 // We weren't continuing and we aren't in backoff. Schedule a normal | 857 // We weren't continuing and we aren't in backoff. Schedule a normal |
| 873 // continuation. | 858 // continuation. |
| 874 if (old_job.purpose == SyncSessionJob::CONFIGURATION) { | 859 if (old_job.purpose == SyncSessionJob::CONFIGURATION) { |
| 875 ScheduleConfigImpl(old_job.session->routing_info(), | 860 ScheduleConfigImpl(old_job.session->routing_info(), |
| 876 old_job.session->workers(), | 861 old_job.session->workers(), |
| 877 GetUpdatesFromNudgeSource(NUDGE_SOURCE_CONTINUATION)); | 862 GetUpdatesFromNudgeSource(NUDGE_SOURCE_CONTINUATION)); |
| 878 } else { | 863 } else { |
| 879 // For all other purposes(nudge and poll) we schedule a retry nudge. | 864 // For all other purposes(nudge and poll) we schedule a retry nudge. |
| 880 ScheduleNudgeImpl(TimeDelta::FromSeconds(0), | 865 ScheduleNudgeImpl(TimeDelta::FromSeconds(0), |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1155 | 1140 |
| 1156 #undef SVLOG_LOC | 1141 #undef SVLOG_LOC |
| 1157 | 1142 |
| 1158 #undef SVLOG | 1143 #undef SVLOG |
| 1159 | 1144 |
| 1160 #undef SLOG | 1145 #undef SLOG |
| 1161 | 1146 |
| 1162 #undef ENUM_CASE | 1147 #undef ENUM_CASE |
| 1163 | 1148 |
| 1164 } // browser_sync | 1149 } // browser_sync |
| OLD | NEW |