| 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/apply_updates_command.h" | 5 #include "sync/engine/apply_updates_command.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "sync/engine/update_applicator.h" | 8 #include "sync/engine/update_applicator.h" |
| 9 #include "sync/sessions/sync_session.h" | 9 #include "sync/sessions/sync_session.h" |
| 10 #include "sync/syncable/directory.h" | 10 #include "sync/syncable/directory.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 dir->GetServerTypesWithUnappliedUpdates(&trans); | 50 dir->GetServerTypesWithUnappliedUpdates(&trans); |
| 51 FullModelTypeSet server_type_restriction; | 51 FullModelTypeSet server_type_restriction; |
| 52 for (FullModelTypeSet::Iterator it = | 52 for (FullModelTypeSet::Iterator it = |
| 53 server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) { | 53 server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) { |
| 54 if (GetGroupForModelType(it.Get(), session->routing_info()) == | 54 if (GetGroupForModelType(it.Get(), session->routing_info()) == |
| 55 session->status_controller().group_restriction()) { | 55 session->status_controller().group_restriction()) { |
| 56 server_type_restriction.Put(it.Get()); | 56 server_type_restriction.Put(it.Get()); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Don't process control type updates here. They will be handled elsewhere. |
| 61 FullModelTypeSet control_types = ToFullModelTypeSet(ControlTypes()); |
| 62 server_type_restriction.RemoveAll(control_types); |
| 63 |
| 60 std::vector<int64> handles; | 64 std::vector<int64> handles; |
| 61 dir->GetUnappliedUpdateMetaHandles( | 65 dir->GetUnappliedUpdateMetaHandles( |
| 62 &trans, server_type_restriction, &handles); | 66 &trans, server_type_restriction, &handles); |
| 63 | 67 |
| 64 UpdateApplicator applicator( | 68 UpdateApplicator applicator( |
| 65 session->context()->resolver(), | 69 session->context()->resolver(), |
| 66 dir->GetCryptographer(&trans), | 70 dir->GetCryptographer(&trans), |
| 67 handles.begin(), handles.end(), session->routing_info(), | 71 handles.begin(), handles.end(), session->routing_info(), |
| 68 session->status_controller().group_restriction()); | 72 session->status_controller().group_restriction()); |
| 69 while (applicator.AttemptOneApplication(&trans)) {} | 73 while (applicator.AttemptOneApplication(&trans)) {} |
| 70 applicator.SaveProgressIntoSessionState( | 74 applicator.SaveProgressIntoSessionState( |
| 71 session->mutable_status_controller()->mutable_conflict_progress(), | 75 session->mutable_status_controller()->mutable_conflict_progress(), |
| 72 session->mutable_status_controller()->mutable_update_progress()); | 76 session->mutable_status_controller()->mutable_update_progress()); |
| 73 | 77 |
| 74 // This might be the first time we've fully completed a sync cycle, for | 78 // This might be the first time we've fully completed a sync cycle, for |
| 75 // some subset of the currently synced datatypes. | 79 // some subset of the currently synced datatypes. |
| 76 const sessions::StatusController& status(session->status_controller()); | 80 const sessions::StatusController& status(session->status_controller()); |
| 77 if (status.ServerSaysNothingMoreToDownload()) { | 81 if (status.ServerSaysNothingMoreToDownload()) { |
| 78 for (ModelTypeSet::Iterator it = | 82 for (ModelTypeSet::Iterator it = |
| 79 status.updates_request_types().First(); it.Good(); it.Inc()) { | 83 status.updates_request_types().First(); it.Good(); it.Inc()) { |
| 84 // Don't set the flag for control types. We didn't process them here. |
| 85 if (IsControlType(it.Get())) |
| 86 continue; |
| 87 |
| 80 // This gets persisted to the directory's backing store. | 88 // This gets persisted to the directory's backing store. |
| 81 dir->set_initial_sync_ended_for_type(it.Get(), true); | 89 dir->set_initial_sync_ended_for_type(it.Get(), true); |
| 82 } | 90 } |
| 83 } | 91 } |
| 84 | 92 |
| 85 return SYNCER_OK; | 93 return SYNCER_OK; |
| 86 } | 94 } |
| 87 | 95 |
| 88 } // namespace syncer | 96 } // namespace syncer |
| OLD | NEW |