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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 return; // Another nudge must have been scheduled in in the meantime. | 773 return; // Another nudge must have been scheduled in in the meantime. |
776 } | 774 } |
777 pending_nudge_.reset(); | 775 pending_nudge_.reset(); |
778 | 776 |
779 // Create the session with the latest model safe table and use it to purge | 777 // Create the session with the latest model safe table and use it to purge |
780 // and update any disabled or modified entries in the job. | 778 // and update any disabled or modified entries in the job. |
781 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source())); | 779 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source())); |
782 | 780 |
783 job.session->RebaseRoutingInfoWithLatest(*session); | 781 job.session->RebaseRoutingInfoWithLatest(*session); |
784 } | 782 } |
785 SDVLOG(2) << "DoSyncSessionJob with " | |
786 << SyncSessionJob::GetPurposeString(job.purpose) << " job"; | |
787 | |
788 SyncerStep begin(SYNCER_END); | 783 SyncerStep begin(SYNCER_END); |
789 SyncerStep end(SYNCER_END); | 784 SyncerStep end(SYNCER_END); |
790 SetSyncerStepsForPurpose(job.purpose, &begin, &end); | 785 SetSyncerStepsForPurpose(job.purpose, &begin, &end); |
791 | 786 |
792 bool has_more_to_sync = true; | 787 SDVLOG(2) << "Calling SyncShare with " |
793 while (ShouldRunJob(job) && has_more_to_sync) { | 788 << SyncSessionJob::GetPurposeString(job.purpose) << "job"; |
794 SDVLOG(2) << "Calling SyncShare."; | 789 syncer_->SyncShare(job.session.get(), begin, end); |
795 // Synchronously perform the sync session from this thread. | 790 SDVLOG(2) << "Done SyncShare."; |
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."; | |
802 | 791 |
803 FinishSyncSessionJob(job); | 792 FinishSyncSessionJob(job); |
804 } | 793 } |
805 | 794 |
806 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { | 795 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { |
807 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 796 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
808 | 797 |
809 // We are interested in recording time between local nudges for datatypes. | 798 // We are interested in recording time between local nudges for datatypes. |
810 // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. | 799 // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. |
811 if (info.updates_source != GetUpdatesCallerInfo::LOCAL) | 800 if (info.updates_source != GetUpdatesCallerInfo::LOCAL) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 AutoReset<bool> protector(&no_scheduling_allowed_, true); | 843 AutoReset<bool> protector(&no_scheduling_allowed_, true); |
855 job.config_params.ready_task.Run(); | 844 job.config_params.ready_task.Run(); |
856 } | 845 } |
857 | 846 |
858 SDVLOG(2) << "Updating the next polling time after SyncMain"; | 847 SDVLOG(2) << "Updating the next polling time after SyncMain"; |
859 ScheduleNextSync(job); | 848 ScheduleNextSync(job); |
860 } | 849 } |
861 | 850 |
862 void SyncSchedulerImpl::ScheduleNextSync(const SyncSessionJob& old_job) { | 851 void SyncSchedulerImpl::ScheduleNextSync(const SyncSessionJob& old_job) { |
863 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 852 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
864 DCHECK(!old_job.session->HasMoreToSync()); | |
865 | |
866 AdjustPolling(&old_job); | 853 AdjustPolling(&old_job); |
867 | 854 |
868 if (old_job.session->Succeeded()) { | 855 if (old_job.session->Succeeded()) { |
869 // Only reset backoff if we actually reached the server. | 856 // Only reset backoff if we actually reached the server. |
870 if (old_job.session->SuccessfullyReachedServer()) | 857 if (old_job.session->SuccessfullyReachedServer()) |
871 wait_interval_.reset(); | 858 wait_interval_.reset(); |
872 SDVLOG(2) << "Job succeeded so not scheduling more jobs"; | 859 SDVLOG(2) << "Job succeeded so not scheduling more jobs"; |
873 return; | 860 return; |
874 } | 861 } |
875 | 862 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 | 1146 |
1160 #undef SDVLOG_LOC | 1147 #undef SDVLOG_LOC |
1161 | 1148 |
1162 #undef SDVLOG | 1149 #undef SDVLOG |
1163 | 1150 |
1164 #undef SLOG | 1151 #undef SLOG |
1165 | 1152 |
1166 #undef ENUM_CASE | 1153 #undef ENUM_CASE |
1167 | 1154 |
1168 } // namespace syncer | 1155 } // namespace syncer |
OLD | NEW |