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

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: Another attempt at detecting errors Created 9 years, 2 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
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/bind.h" 10 #include "base/bind.h"
(...skipping 14 matching lines...) Expand all
25 25
26 using sessions::SyncSession; 26 using sessions::SyncSession;
27 using sessions::SyncSessionSnapshot; 27 using sessions::SyncSessionSnapshot;
28 using sessions::SyncSourceInfo; 28 using sessions::SyncSourceInfo;
29 using syncable::ModelTypePayloadMap; 29 using syncable::ModelTypePayloadMap;
30 using syncable::ModelTypeBitSet; 30 using syncable::ModelTypeBitSet;
31 using sync_pb::GetUpdatesCallerInfo; 31 using sync_pb::GetUpdatesCallerInfo;
32 32
33 namespace { 33 namespace {
34 bool ShouldRequestEarlyExit( 34 bool ShouldRequestEarlyExit(
35 const browser_sync::SyncProtocolError& error) { 35 const browser_sync::SyncOperationResult& error) {
36 switch (error.error_type) { 36 switch (error.error_type) {
37 case browser_sync::SYNC_SUCCESS: 37 case browser_sync::OPERATION_SUCCESS:
38 case browser_sync::MIGRATION_DONE: 38 case browser_sync::MIGRATION_DONE:
39 case browser_sync::THROTTLED: 39 case browser_sync::THROTTLED:
40 case browser_sync::TRANSIENT_ERROR: 40 case browser_sync::TRANSIENT_ERROR:
41 return false; 41 return false;
42 case browser_sync::NOT_MY_BIRTHDAY: 42 case browser_sync::NOT_MY_BIRTHDAY:
43 case browser_sync::CLEAR_PENDING: 43 case browser_sync::CLEAR_PENDING:
44 // If we send terminate sync early then |sync_cycle_ended| notification 44 // If we send terminate sync early then |sync_cycle_ended| notification
45 // would not be sent. If there were no actions then |ACTIONABLE_ERROR| 45 // would not be sent. If there were no actions then |ACTIONABLE_ERROR|
46 // notification wouldnt be sent either. Then the UI layer would be left 46 // notification wouldnt be sent either. Then the UI layer would be left
47 // waiting forever. So assert we would send something. 47 // waiting forever. So assert we would send something.
48 DCHECK(error.action != browser_sync::UNKNOWN_ACTION); 48 DCHECK(error.action != browser_sync::UNKNOWN_ACTION);
49 return true; 49 return true;
50 case browser_sync::INVALID_CREDENTIAL: 50 case browser_sync::INVALID_CREDENTIAL:
51 // The notification for this is handled by PostAndProcessHeaders|. 51 // The notification for this is handled by PostAndProcessHeaders|.
52 // Server does no have to send any action for this. 52 // Server does no have to send any action for this.
53 return true; 53 return true;
54 // Make the default a NOTREACHED. So if a new error is introduced we 54 // Make the default a NOTREACHED. So if a new error is introduced we
55 // think about its expected functionality. 55 // think about its expected functionality.
56 default: 56 default:
57 NOTREACHED(); 57 NOTREACHED();
58 return false; 58 return false;
59 } 59 }
60 } 60 }
61 61
62 bool IsActionableError( 62 bool IsActionableError(
63 const browser_sync::SyncProtocolError& error) { 63 const browser_sync::SyncOperationResult& error) {
64 return (error.action != browser_sync::UNKNOWN_ACTION); 64 return (error.action != browser_sync::UNKNOWN_ACTION);
65 } 65 }
66 } // namespace 66 } // namespace
67 67
68 SyncScheduler::DelayProvider::DelayProvider() {} 68 SyncScheduler::DelayProvider::DelayProvider() {}
69 SyncScheduler::DelayProvider::~DelayProvider() {} 69 SyncScheduler::DelayProvider::~DelayProvider() {}
70 70
71 SyncScheduler::WaitInterval::WaitInterval() 71 SyncScheduler::WaitInterval::WaitInterval()
72 : mode(UNKNOWN), 72 : mode(UNKNOWN),
73 had_nudge(false) { 73 had_nudge(false) {
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 return; // Nothing to do. 814 return; // Nothing to do.
815 } 815 }
816 816
817 SVLOG(2) << "Updating the next polling time after SyncMain"; 817 SVLOG(2) << "Updating the next polling time after SyncMain";
818 ScheduleNextSync(job); 818 ScheduleNextSync(job);
819 } 819 }
820 820
821 void SyncScheduler::ScheduleNextSync(const SyncSessionJob& old_job) { 821 void SyncScheduler::ScheduleNextSync(const SyncSessionJob& old_job) {
822 DCHECK_EQ(MessageLoop::current(), sync_loop_); 822 DCHECK_EQ(MessageLoop::current(), sync_loop_);
823 DCHECK(!old_job.session->HasMoreToSync()); 823 DCHECK(!old_job.session->HasMoreToSync());
824 // Note: |num_server_changes_remaining| > 0 here implies that we received a
825 // broken response while trying to download all updates, because the Syncer
826 // will loop until this value is exhausted. Also, if unsynced_handles exist
827 // but HasMoreToSync is false, this implies that the Syncer determined no
828 // forward progress was possible at this time (an error, such as an HTTP
829 // 500, is likely to have occurred during commit).
830 int num_server_changes_remaining =
831 old_job.session->status_controller()->num_server_changes_remaining();
832 size_t num_unsynced_handles =
833 old_job.session->status_controller()->unsynced_handles().size();
834 const bool work_to_do =
835 num_server_changes_remaining > 0 || num_unsynced_handles > 0;
836 SVLOG(2) << "num server changes remaining: " << num_server_changes_remaining
837 << ", num unsynced handles: " << num_unsynced_handles
838 << ", syncer has work to do: " << work_to_do;
839 824
840 AdjustPolling(&old_job); 825 AdjustPolling(&old_job);
841 826
842 // TODO(tim): Old impl had special code if notifications disabled. Needed? 827 // TODO(tim): Old impl had special code if notifications disabled. Needed?
843 if (!work_to_do) { 828 if (!old_job.session->ExperiencedTransientError()) {
844 // Success implies backoff relief. Note that if this was a 829 // Success implies backoff relief. Note that if this was a
845 // "one-off" job (i.e. purpose == 830 // "one-off" job (i.e. purpose ==
846 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if 831 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if
847 // there was work_to_do before it ran this wont have changed, as 832 // there was work to do before it ran this wont have changed, as
848 // jobs like this don't run a full sync cycle. So we don't need 833 // jobs like this don't run a full sync cycle. So we don't need
849 // special code here. 834 // special code here.
850 wait_interval_.reset(); 835 wait_interval_.reset();
851 SVLOG(2) << "Job succeeded so not scheduling more jobs"; 836 SVLOG(2) << "Job succeeded so not scheduling more jobs";
852 return; 837 return;
853 } 838 }
854 839
855 // We are in backoff mode and our time did not run out. That means we had 840 // We are in backoff mode and our time did not run out. That means we had
856 // a local change, notification from server or a network connection change 841 // a local change, notification from server or a network connection change
857 // notification. In any case set had_nudge = true so we dont retry next 842 // 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
1163 1148
1164 #undef SVLOG_LOC 1149 #undef SVLOG_LOC
1165 1150
1166 #undef SVLOG 1151 #undef SVLOG
1167 1152
1168 #undef SLOG 1153 #undef SLOG
1169 1154
1170 #undef ENUM_CASE 1155 #undef ENUM_CASE
1171 1156
1172 } // browser_sync 1157 } // browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/post_commit_message_command.cc ('k') | chrome/browser/sync/engine/syncer_proto_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698