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 "components/sync/engine_impl/syncer.h" | 5 #include "components/sync/engine_impl/syncer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 bool Syncer::PostClearServerData(SyncCycle* cycle) { | 107 bool Syncer::PostClearServerData(SyncCycle* cycle) { |
| 108 DCHECK(cycle); | 108 DCHECK(cycle); |
| 109 ClearServerData clear_server_data(cycle->context()->account_name()); | 109 ClearServerData clear_server_data(cycle->context()->account_name()); |
| 110 return clear_server_data.SendRequest(cycle) == SYNCER_OK; | 110 return clear_server_data.SendRequest(cycle) == SYNCER_OK; |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool Syncer::DownloadAndApplyUpdates(ModelTypeSet* request_types, | 113 bool Syncer::DownloadAndApplyUpdates(ModelTypeSet* request_types, |
| 114 SyncCycle* cycle, | 114 SyncCycle* cycle, |
| 115 const GetUpdatesDelegate& delegate, | 115 const GetUpdatesDelegate& delegate, |
| 116 bool create_mobile_bookmarks_folder) { | 116 bool create_mobile_bookmarks_folder) { |
| 117 ModelTypeSet add_for_commit = Intersection(*request_types, CommitOnlyTypes()); | |
|
Patrick Noland
2017/06/01 22:58:48
This name made it harder for me to follow what you
skym
2017/06/01 23:15:21
Done.
| |
| 118 ModelTypeSet download_types = Difference(*request_types, add_for_commit); | |
| 117 GetUpdatesProcessor get_updates_processor( | 119 GetUpdatesProcessor get_updates_processor( |
| 118 cycle->context()->model_type_registry()->update_handler_map(), delegate); | 120 cycle->context()->model_type_registry()->update_handler_map(), delegate); |
| 119 SyncerError download_result = UNSET; | 121 SyncerError download_result = UNSET; |
| 120 do { | 122 do { |
| 121 download_result = get_updates_processor.DownloadUpdates( | 123 download_result = get_updates_processor.DownloadUpdates( |
| 122 request_types, cycle, create_mobile_bookmarks_folder); | 124 &download_types, cycle, create_mobile_bookmarks_folder); |
| 123 } while (download_result == SERVER_MORE_TO_DOWNLOAD); | 125 } while (download_result == SERVER_MORE_TO_DOWNLOAD); |
| 124 | 126 |
| 127 // It is our responsibility to propagate the removal of types that occurred in | |
| 128 // GetUpdatesProcessor::DownloadUpdates(). | |
| 129 *request_types = Union(download_types, add_for_commit); | |
| 130 | |
| 125 // Exit without applying if we're shutting down or an error was detected. | 131 // Exit without applying if we're shutting down or an error was detected. |
| 126 if (download_result != SYNCER_OK || ExitRequested()) | 132 if (download_result != SYNCER_OK || ExitRequested()) |
| 127 return false; | 133 return false; |
| 128 | 134 |
| 129 { | 135 { |
| 130 TRACE_EVENT0("sync", "ApplyUpdates"); | 136 TRACE_EVENT0("sync", "ApplyUpdates"); |
| 131 | 137 |
| 132 // Control type updates always get applied first. | 138 // Control type updates always get applied first. |
| 133 ApplyControlDataUpdates(cycle->context()->directory()); | 139 ApplyControlDataUpdates(cycle->context()->directory()); |
| 134 | 140 |
| 135 // Apply updates to the other types. May or may not involve cross-thread | 141 // Apply updates to the other types. May or may not involve cross-thread |
| 136 // traffic, depending on the underlying update handlers and the GU type's | 142 // traffic, depending on the underlying update handlers and the GU type's |
| 137 // delegate. | 143 // delegate. |
| 138 get_updates_processor.ApplyUpdates(*request_types, | 144 get_updates_processor.ApplyUpdates(download_types, |
| 139 cycle->mutable_status_controller()); | 145 cycle->mutable_status_controller()); |
| 140 | 146 |
| 141 cycle->context()->set_hierarchy_conflict_detected( | 147 cycle->context()->set_hierarchy_conflict_detected( |
| 142 cycle->status_controller().num_hierarchy_conflicts() > 0); | 148 cycle->status_controller().num_hierarchy_conflicts() > 0); |
| 143 cycle->SendEventNotification(SyncCycleEvent::STATUS_CHANGED); | 149 cycle->SendEventNotification(SyncCycleEvent::STATUS_CHANGED); |
| 144 } | 150 } |
| 145 | 151 |
| 146 return !ExitRequested(); | 152 return !ExitRequested(); |
| 147 } | 153 } |
| 148 | 154 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 bool success = | 200 bool success = |
| 195 !HasSyncerError(cycle->status_controller().model_neutral_state()); | 201 !HasSyncerError(cycle->status_controller().model_neutral_state()); |
| 196 if (success && source == sync_pb::GetUpdatesCallerInfo::PERIODIC) { | 202 if (success && source == sync_pb::GetUpdatesCallerInfo::PERIODIC) { |
| 197 cycle->mutable_status_controller()->UpdatePollTime(); | 203 cycle->mutable_status_controller()->UpdatePollTime(); |
| 198 } | 204 } |
| 199 | 205 |
| 200 return success; | 206 return success; |
| 201 } | 207 } |
| 202 | 208 |
| 203 } // namespace syncer | 209 } // namespace syncer |
| OLD | NEW |