Chromium Code Reviews| 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.h" | 5 #include "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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 // crbug.com/133030 | 346 // crbug.com/133030 |
| 347 syncer::ModelSafeRoutingInfo restricted_routes; | 347 syncer::ModelSafeRoutingInfo restricted_routes; |
| 348 std::vector<ModelSafeWorker*> restricted_workers; | 348 std::vector<ModelSafeWorker*> restricted_workers; |
| 349 BuildModelSafeParams(params.types_to_download, | 349 BuildModelSafeParams(params.types_to_download, |
| 350 params.routing_info, | 350 params.routing_info, |
| 351 session_context_->workers(), | 351 session_context_->workers(), |
| 352 &restricted_routes, | 352 &restricted_routes, |
| 353 &restricted_workers); | 353 &restricted_workers); |
| 354 session_context_->set_routing_info(params.routing_info); | 354 session_context_->set_routing_info(params.routing_info); |
| 355 | 355 |
| 356 if (params.keystore_key_status == ConfigurationParams::KEYSTORE_KEY_NEEDED) { | 356 // Only perform configure if we have types to download or need to download |
| 357 // TODO(zea): implement in such a way that we can handle failures and the | 357 // the encryption key. |
| 358 // subsequent retrys the scheduler might perform. See crbug.com/129665. | 358 if (params.keystore_key_status == ConfigurationParams::KEYSTORE_KEY_NEEDED || |
| 359 NOTIMPLEMENTED(); | 359 !params.types_to_download.Empty()) { |
| 360 } | |
| 361 | |
| 362 // Only reconfigure if we have types to download. | |
| 363 if (!params.types_to_download.Empty()) { | |
| 364 DCHECK(!restricted_routes.empty()); | |
| 365 linked_ptr<SyncSession> session(new SyncSession( | 360 linked_ptr<SyncSession> session(new SyncSession( |
| 366 session_context_, | 361 session_context_, |
| 367 this, | 362 this, |
| 368 SyncSourceInfo(params.source, | 363 SyncSourceInfo(params.source, |
| 369 ModelSafeRoutingInfoToPayloadMap( | 364 ModelSafeRoutingInfoToPayloadMap( |
| 370 restricted_routes, | 365 restricted_routes, |
| 371 std::string())), | 366 std::string())), |
| 372 restricted_routes, | 367 restricted_routes, |
| 373 restricted_workers)); | 368 restricted_workers)); |
| 374 SyncSessionJob job(SyncSessionJob::CONFIGURATION, | 369 SyncSessionJob job(SyncSessionJob::CONFIGURATION, |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 ENUM_CASE(CONTINUE); | 655 ENUM_CASE(CONTINUE); |
| 661 ENUM_CASE(SAVE); | 656 ENUM_CASE(SAVE); |
| 662 ENUM_CASE(DROP); | 657 ENUM_CASE(DROP); |
| 663 } | 658 } |
| 664 return ""; | 659 return ""; |
| 665 } | 660 } |
| 666 | 661 |
| 667 // static | 662 // static |
| 668 void SyncScheduler::SetSyncerStepsForPurpose( | 663 void SyncScheduler::SetSyncerStepsForPurpose( |
| 669 SyncSessionJob::SyncSessionJobPurpose purpose, | 664 SyncSessionJob::SyncSessionJobPurpose purpose, |
| 665 const ConfigurationParams& config_params, | |
| 670 SyncerStep* start, | 666 SyncerStep* start, |
| 671 SyncerStep* end) { | 667 SyncerStep* end) { |
| 672 switch (purpose) { | 668 switch (purpose) { |
| 673 case SyncSessionJob::CONFIGURATION: | 669 case SyncSessionJob::CONFIGURATION: |
| 674 *start = DOWNLOAD_UPDATES; | 670 DCHECK(config_params.keystore_key_status == |
| 675 *end = APPLY_UPDATES; | 671 ConfigurationParams::KEYSTORE_KEY_NEEDED || |
| 672 !config_params.types_to_download.Empty()); | |
| 673 if (config_params.keystore_key_status == | |
|
tim (not reviewing)
2012/07/19 21:42:03
If it's a separate http request, should we have a
Nicolas Zea
2012/07/24 22:51:24
Based on the discussion with Kevin, moved the GetK
| |
| 674 ConfigurationParams::KEYSTORE_KEY_NEEDED) | |
| 675 *start = GET_ENCRYPTION_KEY; | |
| 676 else | |
| 677 *start = DOWNLOAD_UPDATES; | |
| 678 if (config_params.types_to_download.Empty()) | |
| 679 *end = GET_ENCRYPTION_KEY; | |
| 680 else | |
| 681 *end = APPLY_UPDATES; | |
| 676 return; | 682 return; |
| 677 case SyncSessionJob::NUDGE: | 683 case SyncSessionJob::NUDGE: |
| 678 case SyncSessionJob::POLL: | 684 case SyncSessionJob::POLL: |
| 679 *start = SYNCER_BEGIN; | 685 *start = SYNCER_BEGIN; |
| 680 *end = SYNCER_END; | 686 *end = SYNCER_END; |
| 681 return; | 687 return; |
| 682 default: | 688 default: |
| 683 NOTREACHED(); | 689 NOTREACHED(); |
| 684 *start = SYNCER_END; | 690 *start = SYNCER_END; |
| 685 *end = SYNCER_END; | 691 *end = SYNCER_END; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 760 // and update any disabled or modified entries in the job. | 766 // and update any disabled or modified entries in the job. |
| 761 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source())); | 767 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source())); |
| 762 | 768 |
| 763 job.session->RebaseRoutingInfoWithLatest(*session); | 769 job.session->RebaseRoutingInfoWithLatest(*session); |
| 764 } | 770 } |
| 765 SDVLOG(2) << "DoSyncSessionJob with " | 771 SDVLOG(2) << "DoSyncSessionJob with " |
| 766 << SyncSessionJob::GetPurposeString(job.purpose) << " job"; | 772 << SyncSessionJob::GetPurposeString(job.purpose) << " job"; |
| 767 | 773 |
| 768 SyncerStep begin(SYNCER_END); | 774 SyncerStep begin(SYNCER_END); |
| 769 SyncerStep end(SYNCER_END); | 775 SyncerStep end(SYNCER_END); |
| 770 SetSyncerStepsForPurpose(job.purpose, &begin, &end); | 776 SetSyncerStepsForPurpose(job.purpose, job.config_params, &begin, &end); |
| 771 | 777 |
| 772 bool has_more_to_sync = true; | 778 bool has_more_to_sync = true; |
| 773 while (ShouldRunJob(job) && has_more_to_sync) { | 779 while (ShouldRunJob(job) && has_more_to_sync) { |
| 774 SDVLOG(2) << "Calling SyncShare."; | 780 SDVLOG(2) << "Calling SyncShare."; |
| 775 // Synchronously perform the sync session from this thread. | 781 // Synchronously perform the sync session from this thread. |
| 776 syncer_->SyncShare(job.session.get(), begin, end); | 782 syncer_->SyncShare(job.session.get(), begin, end); |
| 777 has_more_to_sync = job.session->HasMoreToSync(); | 783 has_more_to_sync = job.session->HasMoreToSync(); |
| 778 if (has_more_to_sync) | 784 if (has_more_to_sync) |
| 779 job.session->PrepareForAnotherSyncCycle(); | 785 job.session->PrepareForAnotherSyncCycle(); |
| 780 } | 786 } |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1152 | 1158 |
| 1153 #undef SDVLOG_LOC | 1159 #undef SDVLOG_LOC |
| 1154 | 1160 |
| 1155 #undef SDVLOG | 1161 #undef SDVLOG |
| 1156 | 1162 |
| 1157 #undef SLOG | 1163 #undef SLOG |
| 1158 | 1164 |
| 1159 #undef ENUM_CASE | 1165 #undef ENUM_CASE |
| 1160 | 1166 |
| 1161 } // namespace syncer | 1167 } // namespace syncer |
| OLD | NEW |