| 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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   799  |   799  | 
|   800     job.session->RebaseRoutingInfoWithLatest(*session); |   800     job.session->RebaseRoutingInfoWithLatest(*session); | 
|   801   } |   801   } | 
|   802   SDVLOG(2) << "DoSyncSessionJob with " |   802   SDVLOG(2) << "DoSyncSessionJob with " | 
|   803             << SyncSessionJob::GetPurposeString(job.purpose) << " job"; |   803             << SyncSessionJob::GetPurposeString(job.purpose) << " job"; | 
|   804  |   804  | 
|   805   SyncerStep begin(SYNCER_END); |   805   SyncerStep begin(SYNCER_END); | 
|   806   SyncerStep end(SYNCER_END); |   806   SyncerStep end(SYNCER_END); | 
|   807   SetSyncerStepsForPurpose(job.purpose, &begin, &end); |   807   SetSyncerStepsForPurpose(job.purpose, &begin, &end); | 
|   808  |   808  | 
|   809   bool has_more_to_sync = true; |   809   SDVLOG(2) << "Calling SyncShare."; | 
|   810   while (ShouldRunJob(job) && has_more_to_sync) { |   810   // Synchronously perform the sync session from this thread. | 
|   811     SDVLOG(2) << "Calling SyncShare."; |   811   syncer_->SyncShare(job.session.get(), begin, end); | 
|   812     // Synchronously perform the sync session from this thread. |  | 
|   813     syncer_->SyncShare(job.session.get(), begin, end); |  | 
|   814     has_more_to_sync = job.session->HasMoreToSync(); |  | 
|   815     if (has_more_to_sync) |  | 
|   816       job.session->PrepareForAnotherSyncCycle(); |  | 
|   817   } |  | 
|   818   SDVLOG(2) << "Done SyncShare looping."; |   812   SDVLOG(2) << "Done SyncShare looping."; | 
|   819  |   813  | 
|   820   FinishSyncSessionJob(job); |   814   FinishSyncSessionJob(job); | 
|   821 } |   815 } | 
|   822  |   816  | 
|   823 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { |   817 void SyncSchedulerImpl::UpdateNudgeTimeRecords(const SyncSourceInfo& info) { | 
|   824   DCHECK_EQ(MessageLoop::current(), sync_loop_); |   818   DCHECK_EQ(MessageLoop::current(), sync_loop_); | 
|   825  |   819  | 
|   826   // We are interested in recording time between local nudges for datatypes. |   820   // We are interested in recording time between local nudges for datatypes. | 
|   827   // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. |   821   // TODO(tim): Consider tracking LOCAL_NOTIFICATION as well. | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   871     AutoReset<bool> protector(&no_scheduling_allowed_, true); |   865     AutoReset<bool> protector(&no_scheduling_allowed_, true); | 
|   872     job.config_params.ready_task.Run(); |   866     job.config_params.ready_task.Run(); | 
|   873   } |   867   } | 
|   874  |   868  | 
|   875   SDVLOG(2) << "Updating the next polling time after SyncMain"; |   869   SDVLOG(2) << "Updating the next polling time after SyncMain"; | 
|   876   ScheduleNextSync(job); |   870   ScheduleNextSync(job); | 
|   877 } |   871 } | 
|   878  |   872  | 
|   879 void SyncSchedulerImpl::ScheduleNextSync(const SyncSessionJob& old_job) { |   873 void SyncSchedulerImpl::ScheduleNextSync(const SyncSessionJob& old_job) { | 
|   880   DCHECK_EQ(MessageLoop::current(), sync_loop_); |   874   DCHECK_EQ(MessageLoop::current(), sync_loop_); | 
|   881   DCHECK(!old_job.session->HasMoreToSync()); |  | 
|   882  |  | 
|   883   AdjustPolling(&old_job); |   875   AdjustPolling(&old_job); | 
|   884  |   876  | 
|   885   if (old_job.session->Succeeded()) { |   877   if (old_job.session->Succeeded()) { | 
|   886     // Only reset backoff if we actually reached the server. |   878     // Only reset backoff if we actually reached the server. | 
|   887     if (old_job.session->SuccessfullyReachedServer()) |   879     if (old_job.session->SuccessfullyReachedServer()) | 
|   888       wait_interval_.reset(); |   880       wait_interval_.reset(); | 
|   889     SDVLOG(2) << "Job succeeded so not scheduling more jobs"; |   881     SDVLOG(2) << "Job succeeded so not scheduling more jobs"; | 
|   890     return; |   882     return; | 
|   891   } |   883   } | 
|   892  |   884  | 
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1176  |  1168  | 
|  1177 #undef SDVLOG_LOC |  1169 #undef SDVLOG_LOC | 
|  1178  |  1170  | 
|  1179 #undef SDVLOG |  1171 #undef SDVLOG | 
|  1180  |  1172  | 
|  1181 #undef SLOG |  1173 #undef SLOG | 
|  1182  |  1174  | 
|  1183 #undef ENUM_CASE |  1175 #undef ENUM_CASE | 
|  1184  |  1176  | 
|  1185 }  // namespace syncer |  1177 }  // namespace syncer | 
| OLD | NEW |