| 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 // CommitOnlyTypes() should not be included in the GetUpdates, but should be |
| 118 // included in the Commit. We are given a set of types for our SyncShare, |
| 119 // and we must do this filtering. Note that |request_types| is also an out |
| 120 // param, see below where we update it. |
| 121 ModelTypeSet requested_commit_only_types = |
| 122 Intersection(*request_types, CommitOnlyTypes()); |
| 123 ModelTypeSet download_types = |
| 124 Difference(*request_types, requested_commit_only_types); |
| 117 GetUpdatesProcessor get_updates_processor( | 125 GetUpdatesProcessor get_updates_processor( |
| 118 cycle->context()->model_type_registry()->update_handler_map(), delegate); | 126 cycle->context()->model_type_registry()->update_handler_map(), delegate); |
| 119 SyncerError download_result = UNSET; | 127 SyncerError download_result = UNSET; |
| 120 do { | 128 do { |
| 121 download_result = get_updates_processor.DownloadUpdates( | 129 download_result = get_updates_processor.DownloadUpdates( |
| 122 request_types, cycle, create_mobile_bookmarks_folder); | 130 &download_types, cycle, create_mobile_bookmarks_folder); |
| 123 } while (download_result == SERVER_MORE_TO_DOWNLOAD); | 131 } while (download_result == SERVER_MORE_TO_DOWNLOAD); |
| 124 | 132 |
| 133 // It is our responsibility to propagate the removal of types that occurred in |
| 134 // GetUpdatesProcessor::DownloadUpdates(). |
| 135 *request_types = Union(download_types, requested_commit_only_types); |
| 136 |
| 125 // Exit without applying if we're shutting down or an error was detected. | 137 // Exit without applying if we're shutting down or an error was detected. |
| 126 if (download_result != SYNCER_OK || ExitRequested()) | 138 if (download_result != SYNCER_OK || ExitRequested()) |
| 127 return false; | 139 return false; |
| 128 | 140 |
| 129 { | 141 { |
| 130 TRACE_EVENT0("sync", "ApplyUpdates"); | 142 TRACE_EVENT0("sync", "ApplyUpdates"); |
| 131 | 143 |
| 132 // Control type updates always get applied first. | 144 // Control type updates always get applied first. |
| 133 ApplyControlDataUpdates(cycle->context()->directory()); | 145 ApplyControlDataUpdates(cycle->context()->directory()); |
| 134 | 146 |
| 135 // Apply updates to the other types. May or may not involve cross-thread | 147 // 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 | 148 // traffic, depending on the underlying update handlers and the GU type's |
| 137 // delegate. | 149 // delegate. |
| 138 get_updates_processor.ApplyUpdates(*request_types, | 150 get_updates_processor.ApplyUpdates(download_types, |
| 139 cycle->mutable_status_controller()); | 151 cycle->mutable_status_controller()); |
| 140 | 152 |
| 141 cycle->context()->set_hierarchy_conflict_detected( | 153 cycle->context()->set_hierarchy_conflict_detected( |
| 142 cycle->status_controller().num_hierarchy_conflicts() > 0); | 154 cycle->status_controller().num_hierarchy_conflicts() > 0); |
| 143 cycle->SendEventNotification(SyncCycleEvent::STATUS_CHANGED); | 155 cycle->SendEventNotification(SyncCycleEvent::STATUS_CHANGED); |
| 144 } | 156 } |
| 145 | 157 |
| 146 return !ExitRequested(); | 158 return !ExitRequested(); |
| 147 } | 159 } |
| 148 | 160 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 bool success = | 206 bool success = |
| 195 !HasSyncerError(cycle->status_controller().model_neutral_state()); | 207 !HasSyncerError(cycle->status_controller().model_neutral_state()); |
| 196 if (success && source == sync_pb::GetUpdatesCallerInfo::PERIODIC) { | 208 if (success && source == sync_pb::GetUpdatesCallerInfo::PERIODIC) { |
| 197 cycle->mutable_status_controller()->UpdatePollTime(); | 209 cycle->mutable_status_controller()->UpdatePollTime(); |
| 198 } | 210 } |
| 199 | 211 |
| 200 return success; | 212 return success; |
| 201 } | 213 } |
| 202 | 214 |
| 203 } // namespace syncer | 215 } // namespace syncer |
| OLD | NEW |