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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 cycle->mutable_status_controller()->set_commit_result(commit_result); | 72 cycle->mutable_status_controller()->set_commit_result(commit_result); |
73 | 73 |
74 return HandleCycleEnd(cycle, nudge_tracker->GetLegacySource()); | 74 return HandleCycleEnd(cycle, nudge_tracker->GetLegacySource()); |
75 } | 75 } |
76 | 76 |
77 bool Syncer::ConfigureSyncShare( | 77 bool Syncer::ConfigureSyncShare( |
78 ModelTypeSet request_types, | 78 ModelTypeSet request_types, |
79 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, | 79 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
80 SyncCycle* cycle) { | 80 SyncCycle* cycle) { |
81 base::AutoReset<bool> is_syncing(&is_syncing_, true); | 81 base::AutoReset<bool> is_syncing(&is_syncing_, true); |
| 82 |
| 83 // It is possible during configuration that datatypes get unregistered from |
| 84 // ModelTypeRegistry before scheduled configure sync cycle gets executed. |
| 85 // This happens either because DataTypeController::LoadModels fail and type |
| 86 // need to be stopped or during shutdown when all datatypes are stopped. When |
| 87 // it happens we should adjust set of types to download to only include |
| 88 // registered types. |
| 89 request_types.RetainAll(cycle->context()->GetEnabledTypes()); |
82 VLOG(1) << "Configuring types " << ModelTypeSetToString(request_types); | 90 VLOG(1) << "Configuring types " << ModelTypeSetToString(request_types); |
83 HandleCycleBegin(cycle); | 91 HandleCycleBegin(cycle); |
84 ConfigureGetUpdatesDelegate configure_delegate(source); | 92 ConfigureGetUpdatesDelegate configure_delegate(source); |
85 | 93 |
86 // It is possible during shutdown that datatypes get unregistered from | |
87 // ModelTypeRegistry before scheduled configure sync cycle gets executed. | |
88 // When it happens we should adjust set of types to download to only include | |
89 // registered types. | |
90 if (cancelation_signal_->IsSignalled()) | |
91 request_types.RetainAll(cycle->context()->GetEnabledTypes()); | |
92 | |
93 GetUpdatesProcessor get_updates_processor( | 94 GetUpdatesProcessor get_updates_processor( |
94 cycle->context()->model_type_registry()->update_handler_map(), | 95 cycle->context()->model_type_registry()->update_handler_map(), |
95 configure_delegate); | 96 configure_delegate); |
96 DownloadAndApplyUpdates(&request_types, cycle, &get_updates_processor, | 97 DownloadAndApplyUpdates(&request_types, cycle, &get_updates_processor, |
97 kCreateMobileBookmarksFolder); | 98 kCreateMobileBookmarksFolder); |
98 return HandleCycleEnd(cycle, source); | 99 return HandleCycleEnd(cycle, source); |
99 } | 100 } |
100 | 101 |
101 bool Syncer::PollSyncShare(ModelTypeSet request_types, SyncCycle* cycle) { | 102 bool Syncer::PollSyncShare(ModelTypeSet request_types, SyncCycle* cycle) { |
102 base::AutoReset<bool> is_syncing(&is_syncing_, true); | 103 base::AutoReset<bool> is_syncing(&is_syncing_, true); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 200 } |
200 | 201 |
201 bool Syncer::PostClearServerData(SyncCycle* cycle) { | 202 bool Syncer::PostClearServerData(SyncCycle* cycle) { |
202 DCHECK(cycle); | 203 DCHECK(cycle); |
203 ClearServerData clear_server_data(cycle->context()->account_name()); | 204 ClearServerData clear_server_data(cycle->context()->account_name()); |
204 const SyncerError post_result = clear_server_data.SendRequest(cycle); | 205 const SyncerError post_result = clear_server_data.SendRequest(cycle); |
205 return post_result == SYNCER_OK; | 206 return post_result == SYNCER_OK; |
206 } | 207 } |
207 | 208 |
208 } // namespace syncer | 209 } // namespace syncer |
OLD | NEW |