Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/browser/sync/engine/sync_scheduler.cc

Issue 7861013: Fix the false-positive detection of commit errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renames and refactors Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/sync/sessions/sync_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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->FailedToMakeProgress()) {
836 // Success implies backoff relief. Note that if this was a 821 if (IsBackingOff() && wait_interval_->timer.IsRunning() &&
837 // "one-off" job (i.e. purpose == 822 mode_ == NORMAL_MODE) {
838 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if 823 // We are in backoff mode and our time did not run out. That means we
839 // there was work_to_do before it ran this wont have changed, as 824 // had a local change, notification from server or a network connection
840 // jobs like this don't run a full sync cycle. So we don't need 825 // change notification. In any case set had_nudge = true so we dont
841 // special code here. 826 // retry next nudge.
827 // Note: we will keep retrying network connection changes though as
828 // they are treated as canary jobs. Also we check the mode here because
829 // we want to do this only in normal mode. For config mode jobs we dont
830 // have anything similar to had_nudge.
831 SVLOG(2) << "A nudge during backoff failed";
832 // We weren't continuing but we're in backoff; must have been a nudge.
833 DCHECK_EQ(SyncSessionJob::NUDGE, old_job.purpose);
834 DCHECK(!wait_interval_->had_nudge);
835 wait_interval_->had_nudge = true;
836 // Old job did not finish. So make it the pending job.
837 InitOrCoalescePendingJob(old_job);
838 // Resume waiting.
839 RestartWaiting();
840 } else {
lipalani1 2011/09/22 20:22:46 Can you add the vlog stmt back here?
841 // We seem to have not made forward progress. Start or extend backoff.
842 HandleConsecutiveContinuationError(old_job);
843 }
844 } else {
845 // Success implies backoff relief. Note that if this was a "one-off" job
846 // (i.e. purpose ==
847 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if there was
848 // work to do before it ran this wont have changed, as jobs like this don't
849 // run a full sync cycle. So we don't need special code here.
842 wait_interval_.reset(); 850 wait_interval_.reset();
843 SVLOG(2) << "Job succeeded so not scheduling more jobs"; 851 SVLOG(2) << "Job succeeded so not scheduling more jobs";
844 return;
845 }
846
847 // 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
849 // notification. In any case set had_nudge = true so we dont retry next
850 // nudge. Note: we will keep retrying network connection changes though as
851 // they are treated as canary jobs. Also we check the mode here because
852 // we want to do this only in normal mode. For config mode jobs we dont
853 // have anything similar to had_nudge.
854 if (IsBackingOff() && wait_interval_->timer.IsRunning() &&
855 mode_ == NORMAL_MODE) {
856 SVLOG(2) << "A nudge during backoff failed";
857 // We weren't continuing but we're in backoff; must have been a nudge.
858 DCHECK_EQ(SyncSessionJob::NUDGE, old_job.purpose);
859 DCHECK(!wait_interval_->had_nudge);
860 wait_interval_->had_nudge = true;
861 // Old job did not finish. So make it the pending job.
862 InitOrCoalescePendingJob(old_job);
863 // Resume waiting.
864 RestartWaiting();
865 } else if (old_job.session->source().updates_source ==
866 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION) {
867 SVLOG(2) << "Job failed with source continuation";
868 // We don't seem to have made forward progress. Start or extend backoff.
869 HandleConsecutiveContinuationError(old_job);
870 } else {
871 SVLOG(2) << "Failed. Schedule a job with continuation as source";
872 // We weren't continuing and we aren't in backoff. Schedule a normal
873 // continuation.
874 if (old_job.purpose == SyncSessionJob::CONFIGURATION) {
875 ScheduleConfigImpl(old_job.session->routing_info(),
876 old_job.session->workers(),
877 GetUpdatesFromNudgeSource(NUDGE_SOURCE_CONTINUATION));
878 } else {
879 // For all other purposes(nudge and poll) we schedule a retry nudge.
880 ScheduleNudgeImpl(TimeDelta::FromSeconds(0),
881 GetUpdatesFromNudgeSource(NUDGE_SOURCE_CONTINUATION),
882 old_job.session->source().types, false, FROM_HERE);
883 }
884 } 852 }
885 } 853 }
886 854
887 void SyncScheduler::AdjustPolling(const SyncSessionJob* old_job) { 855 void SyncScheduler::AdjustPolling(const SyncSessionJob* old_job) {
888 DCHECK_EQ(MessageLoop::current(), sync_loop_); 856 DCHECK_EQ(MessageLoop::current(), sync_loop_);
889 857
890 TimeDelta poll = (!session_context_->notifications_enabled()) ? 858 TimeDelta poll = (!session_context_->notifications_enabled()) ?
891 syncer_short_poll_interval_seconds_ : 859 syncer_short_poll_interval_seconds_ :
892 syncer_long_poll_interval_seconds_; 860 syncer_long_poll_interval_seconds_;
893 bool rate_changed = !poll_timer_.IsRunning() || 861 bool rate_changed = !poll_timer_.IsRunning() ||
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 1123
1156 #undef SVLOG_LOC 1124 #undef SVLOG_LOC
1157 1125
1158 #undef SVLOG 1126 #undef SVLOG
1159 1127
1160 #undef SLOG 1128 #undef SLOG
1161 1129
1162 #undef ENUM_CASE 1130 #undef ENUM_CASE
1163 1131
1164 } // browser_sync 1132 } // browser_sync
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/sessions/sync_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698