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

Side by Side Diff: sync/engine/sync_scheduler_impl.cc

Issue 11314008: sync: Follow-up to conflict resolution refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 1 month 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 | « sync/engine/process_updates_command_unittest.cc ('k') | sync/engine/sync_session_job.cc » ('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) 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 "sync/engine/sync_scheduler_impl.h" 5 #include "sync/engine/sync_scheduler_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return ""; 105 return "";
106 } 106 }
107 107
108 GetUpdatesCallerInfo::GetUpdatesSource GetUpdatesFromNudgeSource( 108 GetUpdatesCallerInfo::GetUpdatesSource GetUpdatesFromNudgeSource(
109 NudgeSource source) { 109 NudgeSource source) {
110 switch (source) { 110 switch (source) {
111 case NUDGE_SOURCE_NOTIFICATION: 111 case NUDGE_SOURCE_NOTIFICATION:
112 return GetUpdatesCallerInfo::NOTIFICATION; 112 return GetUpdatesCallerInfo::NOTIFICATION;
113 case NUDGE_SOURCE_LOCAL: 113 case NUDGE_SOURCE_LOCAL:
114 return GetUpdatesCallerInfo::LOCAL; 114 return GetUpdatesCallerInfo::LOCAL;
115 case NUDGE_SOURCE_CONTINUATION:
116 return GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION;
117 case NUDGE_SOURCE_LOCAL_REFRESH: 115 case NUDGE_SOURCE_LOCAL_REFRESH:
118 return GetUpdatesCallerInfo::DATATYPE_REFRESH; 116 return GetUpdatesCallerInfo::DATATYPE_REFRESH;
119 case NUDGE_SOURCE_UNKNOWN: 117 case NUDGE_SOURCE_UNKNOWN:
120 return GetUpdatesCallerInfo::UNKNOWN; 118 return GetUpdatesCallerInfo::UNKNOWN;
121 default: 119 default:
122 NOTREACHED(); 120 NOTREACHED();
123 return GetUpdatesCallerInfo::UNKNOWN; 121 return GetUpdatesCallerInfo::UNKNOWN;
124 } 122 }
125 } 123 }
126 124
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 << ": " << GetDecisionString(decision); 754 << ": " << GetDecisionString(decision);
757 if (decision != CONTINUE) { 755 if (decision != CONTINUE) {
758 if (decision == SAVE) { 756 if (decision == SAVE) {
759 HandleSaveJobDecision(job.Pass()); 757 HandleSaveJobDecision(job.Pass());
760 } else { 758 } else {
761 DCHECK_EQ(decision, DROP); 759 DCHECK_EQ(decision, DROP);
762 } 760 }
763 return false; 761 return false;
764 } 762 }
765 763
766 SDVLOG(2) << "DoSyncSessionJob with " 764 SDVLOG(2) << "Calling SyncShare with "
767 << SyncSessionJob::GetPurposeString(job->purpose()) << " job"; 765 << SyncSessionJob::GetPurposeString(job->purpose()) << " job";
768 766 bool premature_exit = !syncer_->SyncShare(job->mutable_session(),
769 bool has_more_to_sync = true; 767 job->start_step(),
770 bool premature_exit = false; 768 job->end_step());
771 while (DecideOnJob(*job) == CONTINUE && has_more_to_sync) { 769 SDVLOG(2) << "Done SyncShare, returned: " << premature_exit;
772 SDVLOG(2) << "Calling SyncShare.";
773 // Synchronously perform the sync session from this thread.
774 premature_exit = !syncer_->SyncShare(job->mutable_session(),
775 job->start_step(),
776 job->end_step());
777
778 has_more_to_sync = job->session()->HasMoreToSync();
779 if (has_more_to_sync)
780 job->mutable_session()->PrepareForAnotherSyncCycle();
781 }
782 SDVLOG(2) << "Done SyncShare looping.";
783 770
784 return FinishSyncSessionJob(job.Pass(), premature_exit); 771 return FinishSyncSessionJob(job.Pass(), premature_exit);
785 } 772 }
786 773
787 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { 774 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) {
788 DCHECK_EQ(MessageLoop::current(), sync_loop_); 775 DCHECK_EQ(MessageLoop::current(), sync_loop_);
789 776
790 // We are interested in recording time between local nudges for datatypes. 777 // We are interested in recording time between local nudges for datatypes.
791 // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. 778 // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well.
792 if (info.updates_source != GetUpdatesCallerInfo::LOCAL) 779 if (info.updates_source != GetUpdatesCallerInfo::LOCAL)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 } 818 }
832 819
833 SDVLOG(2) << "Updating the next polling time after SyncMain"; 820 SDVLOG(2) << "Updating the next polling time after SyncMain";
834 ScheduleNextSync(job.Pass(), succeeded); 821 ScheduleNextSync(job.Pass(), succeeded);
835 return succeeded; 822 return succeeded;
836 } 823 }
837 824
838 void SyncSchedulerImpl::ScheduleNextSync( 825 void SyncSchedulerImpl::ScheduleNextSync(
839 scoped_ptr<SyncSessionJob> finished_job, bool succeeded) { 826 scoped_ptr<SyncSessionJob> finished_job, bool succeeded) {
840 DCHECK_EQ(MessageLoop::current(), sync_loop_); 827 DCHECK_EQ(MessageLoop::current(), sync_loop_);
841 DCHECK(!finished_job->session()->HasMoreToSync());
842 828
843 AdjustPolling(finished_job.get()); 829 AdjustPolling(finished_job.get());
844 830
845 if (succeeded) { 831 if (succeeded) {
846 // Only reset backoff if we actually reached the server. 832 // Only reset backoff if we actually reached the server.
847 // It's possible that we reached the server on one attempt, then had an 833 // It's possible that we reached the server on one attempt, then had an
848 // error on the next (or didn't perform some of the server-communicating 834 // error on the next (or didn't perform some of the server-communicating
849 // commands). We want to verify that, for all commands attempted, we 835 // commands). We want to verify that, for all commands attempted, we
850 // successfully spoke with the server. Therefore, we verify no errors 836 // successfully spoke with the server. Therefore, we verify no errors
851 // and at least one SYNCER_OK. 837 // and at least one SYNCER_OK.
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 1164
1179 #undef SDVLOG_LOC 1165 #undef SDVLOG_LOC
1180 1166
1181 #undef SDVLOG 1167 #undef SDVLOG
1182 1168
1183 #undef SLOG 1169 #undef SLOG
1184 1170
1185 #undef ENUM_CASE 1171 #undef ENUM_CASE
1186 1172
1187 } // namespace syncer 1173 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/process_updates_command_unittest.cc ('k') | sync/engine/sync_session_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698