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->ExperiencedTransientError()) { |
|
tim (not reviewing)
2011/09/27 21:20:07
We should add a comment here along the lines of if
rlarocque
2011/09/27 23:42:41
Is this to prevent readers from assuming that this
| |
| 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 305 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 |