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 "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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return ""; | 133 return ""; |
134 } | 134 } |
135 | 135 |
136 GetUpdatesCallerInfo::GetUpdatesSource GetUpdatesFromNudgeSource( | 136 GetUpdatesCallerInfo::GetUpdatesSource GetUpdatesFromNudgeSource( |
137 NudgeSource source) { | 137 NudgeSource source) { |
138 switch (source) { | 138 switch (source) { |
139 case NUDGE_SOURCE_NOTIFICATION: | 139 case NUDGE_SOURCE_NOTIFICATION: |
140 return GetUpdatesCallerInfo::NOTIFICATION; | 140 return GetUpdatesCallerInfo::NOTIFICATION; |
141 case NUDGE_SOURCE_LOCAL: | 141 case NUDGE_SOURCE_LOCAL: |
142 return GetUpdatesCallerInfo::LOCAL; | 142 return GetUpdatesCallerInfo::LOCAL; |
143 case NUDGE_SOURCE_CONTINUATION: | |
144 return GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION; | |
145 case NUDGE_SOURCE_LOCAL_REFRESH: | 143 case NUDGE_SOURCE_LOCAL_REFRESH: |
146 return GetUpdatesCallerInfo::DATATYPE_REFRESH; | 144 return GetUpdatesCallerInfo::DATATYPE_REFRESH; |
147 case NUDGE_SOURCE_UNKNOWN: | 145 case NUDGE_SOURCE_UNKNOWN: |
148 return GetUpdatesCallerInfo::UNKNOWN; | 146 return GetUpdatesCallerInfo::UNKNOWN; |
149 default: | 147 default: |
150 NOTREACHED(); | 148 NOTREACHED(); |
151 return GetUpdatesCallerInfo::UNKNOWN; | 149 return GetUpdatesCallerInfo::UNKNOWN; |
152 } | 150 } |
153 } | 151 } |
154 | 152 |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 780 |
783 job.session->RebaseRoutingInfoWithLatest(*session); | 781 job.session->RebaseRoutingInfoWithLatest(*session); |
784 } | 782 } |
785 SDVLOG(2) << "DoSyncSessionJob with " | 783 SDVLOG(2) << "DoSyncSessionJob with " |
786 << SyncSessionJob::GetPurposeString(job.purpose) << " job"; | 784 << SyncSessionJob::GetPurposeString(job.purpose) << " job"; |
787 | 785 |
788 SyncerStep begin(SYNCER_END); | 786 SyncerStep begin(SYNCER_END); |
789 SyncerStep end(SYNCER_END); | 787 SyncerStep end(SYNCER_END); |
790 SetSyncerStepsForPurpose(job.purpose, &begin, &end); | 788 SetSyncerStepsForPurpose(job.purpose, &begin, &end); |
791 | 789 |
792 bool has_more_to_sync = true; | 790 SDVLOG(2) << "Calling SyncShare."; |
793 while (ShouldRunJob(job) && has_more_to_sync) { | 791 // Synchronously perform the sync session from this thread. |
794 SDVLOG(2) << "Calling SyncShare."; | 792 syncer_->SyncShare(job.session.get(), begin, end); |
795 // Synchronously perform the sync session from this thread. | |
796 syncer_->SyncShare(job.session.get(), begin, end); | |
797 has_more_to_sync = job.session->HasMoreToSync(); | |
798 if (has_more_to_sync) | |
799 job.session->PrepareForAnotherSyncCycle(); | |
800 } | |
801 SDVLOG(2) << "Done SyncShare looping."; | 793 SDVLOG(2) << "Done SyncShare looping."; |
802 | 794 |
803 FinishSyncSessionJob(job); | 795 FinishSyncSessionJob(job); |
804 } | 796 } |
805 | 797 |
806 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { | 798 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { |
807 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 799 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
808 | 800 |
809 // We are interested in recording time between local nudges for datatypes. | 801 // We are interested in recording time between local nudges for datatypes. |
810 // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. | 802 // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 AutoReset<bool> protector(&no_scheduling_allowed_, true); | 846 AutoReset<bool> protector(&no_scheduling_allowed_, true); |
855 job.config_params.ready_task.Run(); | 847 job.config_params.ready_task.Run(); |
856 } | 848 } |
857 | 849 |
858 SDVLOG(2) << "Updating the next polling time after SyncMain"; | 850 SDVLOG(2) << "Updating the next polling time after SyncMain"; |
859 ScheduleNextSync(job); | 851 ScheduleNextSync(job); |
860 } | 852 } |
861 | 853 |
862 void SyncSchedulerImpl::ScheduleNextSync(const SyncSessionJob& old_job) { | 854 void SyncSchedulerImpl::ScheduleNextSync(const SyncSessionJob& old_job) { |
863 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 855 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
864 DCHECK(!old_job.session->HasMoreToSync()); | |
865 | |
866 AdjustPolling(&old_job); | 856 AdjustPolling(&old_job); |
867 | 857 |
868 if (old_job.session->Succeeded()) { | 858 if (old_job.session->Succeeded()) { |
869 // Only reset backoff if we actually reached the server. | 859 // Only reset backoff if we actually reached the server. |
870 if (old_job.session->SuccessfullyReachedServer()) | 860 if (old_job.session->SuccessfullyReachedServer()) |
871 wait_interval_.reset(); | 861 wait_interval_.reset(); |
872 SDVLOG(2) << "Job succeeded so not scheduling more jobs"; | 862 SDVLOG(2) << "Job succeeded so not scheduling more jobs"; |
873 return; | 863 return; |
874 } | 864 } |
875 | 865 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 | 1149 |
1160 #undef SDVLOG_LOC | 1150 #undef SDVLOG_LOC |
1161 | 1151 |
1162 #undef SDVLOG | 1152 #undef SDVLOG |
1163 | 1153 |
1164 #undef SLOG | 1154 #undef SLOG |
1165 | 1155 |
1166 #undef ENUM_CASE | 1156 #undef ENUM_CASE |
1167 | 1157 |
1168 } // namespace syncer | 1158 } // namespace syncer |
OLD | NEW |