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 "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/bind.h" | 10 #include "base/bind.h" |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 // "one-off" job (i.e. purpose == | 892 // "one-off" job (i.e. purpose == |
893 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if | 893 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if |
894 // there was work to do before it ran this wont have changed, as | 894 // there was work to do before it ran this wont have changed, as |
895 // jobs like this don't run a full sync cycle. So we don't need | 895 // jobs like this don't run a full sync cycle. So we don't need |
896 // special code here. | 896 // special code here. |
897 wait_interval_.reset(); | 897 wait_interval_.reset(); |
898 SDVLOG(2) << "Job succeeded so not scheduling more jobs"; | 898 SDVLOG(2) << "Job succeeded so not scheduling more jobs"; |
899 return; | 899 return; |
900 } | 900 } |
901 | 901 |
| 902 if (old_job.purpose == SyncSessionJob::POLL) { |
| 903 return; // We don't retry POLL jobs. |
| 904 } |
| 905 |
902 // TODO(rlarocque): There's no reason why we should blindly backoff and retry | 906 // TODO(rlarocque): There's no reason why we should blindly backoff and retry |
903 // if we don't succeed. Some types of errors are not likely to disappear on | 907 // if we don't succeed. Some types of errors are not likely to disappear on |
904 // their own. With the return values now available in the old_job.session, we | 908 // their own. With the return values now available in the old_job.session, we |
905 // should be able to detect such errors and only retry when we detect | 909 // should be able to detect such errors and only retry when we detect |
906 // transient errors. | 910 // transient errors. |
907 | 911 |
908 // We are in backoff mode and our time did not run out. That means we had | |
909 // a local change, notification from server or a network connection change | |
910 // notification. In any case set had_nudge = true so we dont retry next | |
911 // nudge. Note: we will keep retrying network connection changes though as | |
912 // they are treated as canary jobs. Also we check the mode here because | |
913 // we want to do this only in normal mode. For config mode jobs we dont | |
914 // have anything similar to had_nudge. | |
915 if (IsBackingOff() && wait_interval_->timer.IsRunning() && | 912 if (IsBackingOff() && wait_interval_->timer.IsRunning() && |
916 mode_ == NORMAL_MODE) { | 913 mode_ == NORMAL_MODE) { |
| 914 // When in normal mode, we allow up to one nudge per backoff interval. It |
| 915 // appears that this was our nudge for this interval, and it failed. |
| 916 // |
| 917 // Note: This does not prevent us from running canary jobs. For example, an |
| 918 // IP address change might still result in another nudge being executed |
| 919 // during this backoff interval. |
917 SDVLOG(2) << "A nudge during backoff failed"; | 920 SDVLOG(2) << "A nudge during backoff failed"; |
918 // We weren't continuing but we're in backoff; must have been a nudge. | 921 |
919 DCHECK_EQ(SyncSessionJob::NUDGE, old_job.purpose); | 922 DCHECK_EQ(SyncSessionJob::NUDGE, old_job.purpose); |
920 DCHECK(!wait_interval_->had_nudge); | 923 DCHECK(!wait_interval_->had_nudge); |
| 924 |
921 wait_interval_->had_nudge = true; | 925 wait_interval_->had_nudge = true; |
922 // Old job did not finish. So make it the pending job. | |
923 InitOrCoalescePendingJob(old_job); | 926 InitOrCoalescePendingJob(old_job); |
924 // Resume waiting. | |
925 RestartWaiting(); | 927 RestartWaiting(); |
926 } else { | 928 } else { |
| 929 // Either this is the first failure or a consecutive failure after our |
| 930 // backoff timer expired. We handle it the same way in either case. |
927 SDVLOG(2) << "Non-'backoff nudge' SyncShare job failed"; | 931 SDVLOG(2) << "Non-'backoff nudge' SyncShare job failed"; |
928 // We don't seem to have made forward progress. Start or extend backoff. | |
929 HandleContinuationError(old_job); | 932 HandleContinuationError(old_job); |
930 } | 933 } |
931 } | 934 } |
932 | 935 |
933 void SyncScheduler::AdjustPolling(const SyncSessionJob* old_job) { | 936 void SyncScheduler::AdjustPolling(const SyncSessionJob* old_job) { |
934 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 937 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
935 | 938 |
936 TimeDelta poll = (!session_context_->notifications_enabled()) ? | 939 TimeDelta poll = (!session_context_->notifications_enabled()) ? |
937 syncer_short_poll_interval_seconds_ : | 940 syncer_short_poll_interval_seconds_ : |
938 syncer_long_poll_interval_seconds_; | 941 syncer_long_poll_interval_seconds_; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 | 1207 |
1205 #undef SDVLOG_LOC | 1208 #undef SDVLOG_LOC |
1206 | 1209 |
1207 #undef SDVLOG | 1210 #undef SDVLOG |
1208 | 1211 |
1209 #undef SLOG | 1212 #undef SLOG |
1210 | 1213 |
1211 #undef ENUM_CASE | 1214 #undef ENUM_CASE |
1212 | 1215 |
1213 } // browser_sync | 1216 } // browser_sync |
OLD | NEW |