| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/driver/ui_data_type_controller.h" | 5 #include "components/sync/driver/ui_data_type_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "components/sync/api/data_type_error_handler_impl.h" | 14 #include "components/sync/api/data_type_error_handler_impl.h" |
| 15 #include "components/sync/api/sync_error.h" | 15 #include "components/sync/api/sync_error.h" |
| 16 #include "components/sync/api/sync_merge_result.h" | 16 #include "components/sync/api/sync_merge_result.h" |
| 17 #include "components/sync/api/syncable_service.h" | 17 #include "components/sync/api/syncable_service.h" |
| 18 #include "components/sync/base/data_type_histogram.h" | 18 #include "components/sync/base/data_type_histogram.h" |
| 19 #include "components/sync/base/model_type.h" | 19 #include "components/sync/base/model_type.h" |
| 20 #include "components/sync/driver/generic_change_processor_factory.h" | 20 #include "components/sync/driver/generic_change_processor_factory.h" |
| 21 #include "components/sync/driver/shared_change_processor_ref.h" | 21 #include "components/sync/driver/shared_change_processor_ref.h" |
| 22 #include "components/sync/driver/sync_client.h" | 22 #include "components/sync/driver/sync_client.h" |
| 23 #include "components/sync/driver/sync_service.h" | 23 #include "components/sync/driver/sync_service.h" |
| 24 | 24 |
| 25 namespace syncer { | 25 namespace sync_driver { |
| 26 | 26 |
| 27 UIDataTypeController::UIDataTypeController() | 27 UIDataTypeController::UIDataTypeController() |
| 28 : DirectoryDataTypeController(UNSPECIFIED, base::Closure(), nullptr), | 28 : DirectoryDataTypeController(syncer::UNSPECIFIED, |
| 29 base::Closure(), |
| 30 nullptr), |
| 29 state_(NOT_RUNNING) {} | 31 state_(NOT_RUNNING) {} |
| 30 | 32 |
| 31 UIDataTypeController::UIDataTypeController(ModelType type, | 33 UIDataTypeController::UIDataTypeController(syncer::ModelType type, |
| 32 const base::Closure& dump_stack, | 34 const base::Closure& dump_stack, |
| 33 SyncClient* sync_client) | 35 SyncClient* sync_client) |
| 34 : DirectoryDataTypeController(type, dump_stack, sync_client), | 36 : DirectoryDataTypeController(type, dump_stack, sync_client), |
| 35 state_(NOT_RUNNING), | 37 state_(NOT_RUNNING), |
| 36 processor_factory_(new GenericChangeProcessorFactory()) { | 38 processor_factory_(new GenericChangeProcessorFactory()) { |
| 37 DCHECK(IsRealDataType(type)); | 39 DCHECK(syncer::IsRealDataType(type)); |
| 38 } | 40 } |
| 39 | 41 |
| 40 void UIDataTypeController::SetGenericChangeProcessorFactoryForTest( | 42 void UIDataTypeController::SetGenericChangeProcessorFactoryForTest( |
| 41 std::unique_ptr<GenericChangeProcessorFactory> factory) { | 43 std::unique_ptr<GenericChangeProcessorFactory> factory) { |
| 42 DCHECK_EQ(state_, NOT_RUNNING); | 44 DCHECK_EQ(state_, NOT_RUNNING); |
| 43 processor_factory_ = std::move(factory); | 45 processor_factory_ = std::move(factory); |
| 44 } | 46 } |
| 45 | 47 |
| 46 UIDataTypeController::~UIDataTypeController() {} | 48 UIDataTypeController::~UIDataTypeController() {} |
| 47 | 49 |
| 48 void UIDataTypeController::LoadModels( | 50 void UIDataTypeController::LoadModels( |
| 49 const ModelLoadCallback& model_load_callback) { | 51 const ModelLoadCallback& model_load_callback) { |
| 50 DCHECK(CalledOnValidThread()); | 52 DCHECK(CalledOnValidThread()); |
| 51 DCHECK(IsRealDataType(type())); | 53 DCHECK(syncer::IsRealDataType(type())); |
| 52 model_load_callback_ = model_load_callback; | 54 model_load_callback_ = model_load_callback; |
| 53 if (state_ != NOT_RUNNING) { | 55 if (state_ != NOT_RUNNING) { |
| 54 model_load_callback.Run(type(), | 56 model_load_callback.Run( |
| 55 SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, | 57 type(), syncer::SyncError(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, |
| 56 "Model already loaded", type())); | 58 "Model already loaded", type())); |
| 57 return; | 59 return; |
| 58 } | 60 } |
| 59 // Since we can't be called multiple times before Stop() is called, | 61 // Since we can't be called multiple times before Stop() is called, |
| 60 // |shared_change_processor_| must be NULL here. | 62 // |shared_change_processor_| must be NULL here. |
| 61 DCHECK(!shared_change_processor_.get()); | 63 DCHECK(!shared_change_processor_.get()); |
| 62 shared_change_processor_ = new SharedChangeProcessor(type()); | 64 shared_change_processor_ = new SharedChangeProcessor(type()); |
| 63 | 65 |
| 64 state_ = MODEL_STARTING; | 66 state_ = MODEL_STARTING; |
| 65 if (!StartModels()) { | 67 if (!StartModels()) { |
| 66 // If we are waiting for some external service to load before associating | 68 // If we are waiting for some external service to load before associating |
| 67 // or we failed to start the models, we exit early. state_ will control | 69 // or we failed to start the models, we exit early. state_ will control |
| 68 // what we perform next. | 70 // what we perform next. |
| 69 DCHECK(state_ == NOT_RUNNING || state_ == MODEL_STARTING); | 71 DCHECK(state_ == NOT_RUNNING || state_ == MODEL_STARTING); |
| 70 return; | 72 return; |
| 71 } | 73 } |
| 72 | 74 |
| 73 state_ = MODEL_LOADED; | 75 state_ = MODEL_LOADED; |
| 74 model_load_callback_.Run(type(), SyncError()); | 76 model_load_callback_.Run(type(), syncer::SyncError()); |
| 75 } | 77 } |
| 76 | 78 |
| 77 void UIDataTypeController::OnModelLoaded() { | 79 void UIDataTypeController::OnModelLoaded() { |
| 78 DCHECK(CalledOnValidThread()); | 80 DCHECK(CalledOnValidThread()); |
| 79 DCHECK_EQ(state_, MODEL_STARTING); | 81 DCHECK_EQ(state_, MODEL_STARTING); |
| 80 | 82 |
| 81 state_ = MODEL_LOADED; | 83 state_ = MODEL_LOADED; |
| 82 model_load_callback_.Run(type(), SyncError()); | 84 model_load_callback_.Run(type(), syncer::SyncError()); |
| 83 } | 85 } |
| 84 | 86 |
| 85 void UIDataTypeController::StartAssociating( | 87 void UIDataTypeController::StartAssociating( |
| 86 const StartCallback& start_callback) { | 88 const StartCallback& start_callback) { |
| 87 DCHECK(CalledOnValidThread()); | 89 DCHECK(CalledOnValidThread()); |
| 88 DCHECK(!start_callback.is_null()); | 90 DCHECK(!start_callback.is_null()); |
| 89 DCHECK_EQ(state_, MODEL_LOADED); | 91 DCHECK_EQ(state_, MODEL_LOADED); |
| 90 | 92 |
| 91 start_callback_ = start_callback; | 93 start_callback_ = start_callback; |
| 92 state_ = ASSOCIATING; | 94 state_ = ASSOCIATING; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 103 } | 105 } |
| 104 | 106 |
| 105 void UIDataTypeController::Associate() { | 107 void UIDataTypeController::Associate() { |
| 106 DCHECK(CalledOnValidThread()); | 108 DCHECK(CalledOnValidThread()); |
| 107 if (state_ != ASSOCIATING) { | 109 if (state_ != ASSOCIATING) { |
| 108 // Stop() must have been called while Associate() task have been waiting. | 110 // Stop() must have been called while Associate() task have been waiting. |
| 109 DCHECK_EQ(state_, NOT_RUNNING); | 111 DCHECK_EQ(state_, NOT_RUNNING); |
| 110 return; | 112 return; |
| 111 } | 113 } |
| 112 | 114 |
| 113 SyncMergeResult local_merge_result(type()); | 115 syncer::SyncMergeResult local_merge_result(type()); |
| 114 SyncMergeResult syncer_merge_result(type()); | 116 syncer::SyncMergeResult syncer_merge_result(type()); |
| 115 base::WeakPtrFactory<SyncMergeResult> weak_ptr_factory(&syncer_merge_result); | 117 base::WeakPtrFactory<syncer::SyncMergeResult> weak_ptr_factory( |
| 118 &syncer_merge_result); |
| 116 | 119 |
| 117 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 120 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
| 118 // fixed. | 121 // fixed. |
| 119 tracked_objects::ScopedTracker tracking_profile1( | 122 tracked_objects::ScopedTracker tracking_profile1( |
| 120 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 123 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 121 "471403 UIDataTypeController::Associate1")); | 124 "471403 UIDataTypeController::Associate1")); |
| 122 | 125 |
| 123 // Connect |shared_change_processor_| to the syncer and get the | 126 // Connect |shared_change_processor_| to the syncer and get the |
| 124 // SyncableService associated with type(). | 127 // syncer::SyncableService associated with type(). |
| 125 DCHECK(sync_client_->GetSyncService()); | 128 DCHECK(sync_client_->GetSyncService()); |
| 126 local_service_ = shared_change_processor_->Connect( | 129 local_service_ = shared_change_processor_->Connect( |
| 127 sync_client_, processor_factory_.get(), | 130 sync_client_, processor_factory_.get(), |
| 128 sync_client_->GetSyncService()->GetUserShare(), CreateErrorHandler(), | 131 sync_client_->GetSyncService()->GetUserShare(), CreateErrorHandler(), |
| 129 weak_ptr_factory.GetWeakPtr()); | 132 weak_ptr_factory.GetWeakPtr()); |
| 130 if (!local_service_.get()) { | 133 if (!local_service_.get()) { |
| 131 SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, | 134 syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, |
| 132 "Failed to connect to syncer.", type()); | 135 "Failed to connect to syncer.", type()); |
| 133 local_merge_result.set_error(error); | 136 local_merge_result.set_error(error); |
| 134 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); | 137 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); |
| 135 return; | 138 return; |
| 136 } | 139 } |
| 137 | 140 |
| 138 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 141 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
| 139 // fixed. | 142 // fixed. |
| 140 tracked_objects::ScopedTracker tracking_profile2( | 143 tracked_objects::ScopedTracker tracking_profile2( |
| 141 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 144 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 142 "471403 UIDataTypeController::Associate2")); | 145 "471403 UIDataTypeController::Associate2")); |
| 143 if (!shared_change_processor_->CryptoReadyIfNecessary()) { | 146 if (!shared_change_processor_->CryptoReadyIfNecessary()) { |
| 144 SyncError error(FROM_HERE, SyncError::CRYPTO_ERROR, "", type()); | 147 syncer::SyncError error(FROM_HERE, syncer::SyncError::CRYPTO_ERROR, "", |
| 148 type()); |
| 145 local_merge_result.set_error(error); | 149 local_merge_result.set_error(error); |
| 146 StartDone(NEEDS_CRYPTO, local_merge_result, syncer_merge_result); | 150 StartDone(NEEDS_CRYPTO, local_merge_result, syncer_merge_result); |
| 147 return; | 151 return; |
| 148 } | 152 } |
| 149 | 153 |
| 150 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 154 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
| 151 // fixed. | 155 // fixed. |
| 152 tracked_objects::ScopedTracker tracking_profile3( | 156 tracked_objects::ScopedTracker tracking_profile3( |
| 153 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 157 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 154 "471403 UIDataTypeController::Associate3")); | 158 "471403 UIDataTypeController::Associate3")); |
| 155 bool sync_has_nodes = false; | 159 bool sync_has_nodes = false; |
| 156 if (!shared_change_processor_->SyncModelHasUserCreatedNodes( | 160 if (!shared_change_processor_->SyncModelHasUserCreatedNodes( |
| 157 &sync_has_nodes)) { | 161 &sync_has_nodes)) { |
| 158 SyncError error(FROM_HERE, SyncError::UNRECOVERABLE_ERROR, | 162 syncer::SyncError error(FROM_HERE, syncer::SyncError::UNRECOVERABLE_ERROR, |
| 159 "Failed to load sync nodes", type()); | 163 "Failed to load sync nodes", type()); |
| 160 local_merge_result.set_error(error); | 164 local_merge_result.set_error(error); |
| 161 StartDone(UNRECOVERABLE_ERROR, local_merge_result, syncer_merge_result); | 165 StartDone(UNRECOVERABLE_ERROR, local_merge_result, syncer_merge_result); |
| 162 return; | 166 return; |
| 163 } | 167 } |
| 164 | 168 |
| 165 // Scope for |initial_sync_data| which might be expensive, so we don't want | 169 // Scope for |initial_sync_data| which might be expensive, so we don't want |
| 166 // to keep it in memory longer than necessary. | 170 // to keep it in memory longer than necessary. |
| 167 { | 171 { |
| 168 SyncDataList initial_sync_data; | 172 syncer::SyncDataList initial_sync_data; |
| 169 | 173 |
| 170 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 | 174 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 |
| 171 // is fixed. | 175 // is fixed. |
| 172 tracked_objects::ScopedTracker tracking_profile4( | 176 tracked_objects::ScopedTracker tracking_profile4( |
| 173 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 177 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 174 "471403 UIDataTypeController::Associate4")); | 178 "471403 UIDataTypeController::Associate4")); |
| 175 base::TimeTicks start_time = base::TimeTicks::Now(); | 179 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 176 SyncError error = shared_change_processor_->GetAllSyncDataReturnError( | 180 syncer::SyncError error = |
| 177 type(), &initial_sync_data); | 181 shared_change_processor_->GetAllSyncDataReturnError(type(), |
| 182 &initial_sync_data); |
| 178 if (error.IsSet()) { | 183 if (error.IsSet()) { |
| 179 local_merge_result.set_error(error); | 184 local_merge_result.set_error(error); |
| 180 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); | 185 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); |
| 181 return; | 186 return; |
| 182 } | 187 } |
| 183 | 188 |
| 184 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 | 189 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 |
| 185 // is fixed. | 190 // is fixed. |
| 186 tracked_objects::ScopedTracker tracking_profile5( | 191 tracked_objects::ScopedTracker tracking_profile5( |
| 187 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 192 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 188 "471403 UIDataTypeController::Associate5")); | 193 "471403 UIDataTypeController::Associate5")); |
| 189 std::string datatype_context; | 194 std::string datatype_context; |
| 190 if (shared_change_processor_->GetDataTypeContext(&datatype_context)) { | 195 if (shared_change_processor_->GetDataTypeContext(&datatype_context)) { |
| 191 local_service_->UpdateDataTypeContext( | 196 local_service_->UpdateDataTypeContext( |
| 192 type(), SyncChangeProcessor::NO_REFRESH, datatype_context); | 197 type(), syncer::SyncChangeProcessor::NO_REFRESH, datatype_context); |
| 193 } | 198 } |
| 194 | 199 |
| 195 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 | 200 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 |
| 196 // is fixed. | 201 // is fixed. |
| 197 tracked_objects::ScopedTracker tracking_profile6( | 202 tracked_objects::ScopedTracker tracking_profile6( |
| 198 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 203 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 199 "471403 UIDataTypeController::Associate6")); | 204 "471403 UIDataTypeController::Associate6")); |
| 200 syncer_merge_result.set_num_items_before_association( | 205 syncer_merge_result.set_num_items_before_association( |
| 201 initial_sync_data.size()); | 206 initial_sync_data.size()); |
| 202 // Passes a reference to |shared_change_processor_|. | 207 // Passes a reference to |shared_change_processor_|. |
| 203 local_merge_result = local_service_->MergeDataAndStartSyncing( | 208 local_merge_result = local_service_->MergeDataAndStartSyncing( |
| 204 type(), initial_sync_data, | 209 type(), initial_sync_data, |
| 205 std::unique_ptr<SyncChangeProcessor>( | 210 std::unique_ptr<syncer::SyncChangeProcessor>( |
| 206 new SharedChangeProcessorRef(shared_change_processor_)), | 211 new SharedChangeProcessorRef(shared_change_processor_)), |
| 207 std::unique_ptr<SyncErrorFactory>( | 212 std::unique_ptr<syncer::SyncErrorFactory>( |
| 208 new SharedChangeProcessorRef(shared_change_processor_))); | 213 new SharedChangeProcessorRef(shared_change_processor_))); |
| 209 RecordAssociationTime(base::TimeTicks::Now() - start_time); | 214 RecordAssociationTime(base::TimeTicks::Now() - start_time); |
| 210 if (local_merge_result.error().IsSet()) { | 215 if (local_merge_result.error().IsSet()) { |
| 211 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); | 216 StartDone(ASSOCIATION_FAILED, local_merge_result, syncer_merge_result); |
| 212 return; | 217 return; |
| 213 } | 218 } |
| 214 } | 219 } |
| 215 | 220 |
| 216 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 221 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
| 217 // fixed. | 222 // fixed. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 239 shared_change_processor_ = NULL; | 244 shared_change_processor_ = NULL; |
| 240 } | 245 } |
| 241 | 246 |
| 242 // We don't want to continue loading models (e.g OnModelLoaded should never be | 247 // We don't want to continue loading models (e.g OnModelLoaded should never be |
| 243 // called after we've decided to abort). | 248 // called after we've decided to abort). |
| 244 StopModels(); | 249 StopModels(); |
| 245 } | 250 } |
| 246 | 251 |
| 247 void UIDataTypeController::StartDone( | 252 void UIDataTypeController::StartDone( |
| 248 ConfigureResult start_result, | 253 ConfigureResult start_result, |
| 249 const SyncMergeResult& local_merge_result, | 254 const syncer::SyncMergeResult& local_merge_result, |
| 250 const SyncMergeResult& syncer_merge_result) { | 255 const syncer::SyncMergeResult& syncer_merge_result) { |
| 251 DCHECK(CalledOnValidThread()); | 256 DCHECK(CalledOnValidThread()); |
| 252 | 257 |
| 253 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is | 258 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/471403 is |
| 254 // fixed. | 259 // fixed. |
| 255 tracked_objects::ScopedTracker tracking_profile( | 260 tracked_objects::ScopedTracker tracking_profile( |
| 256 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 261 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 257 "471403 UIDataTypeController::StartDone")); | 262 "471403 UIDataTypeController::StartDone")); |
| 258 | 263 |
| 259 if (!IsSuccessfulResult(start_result)) { | 264 if (!IsSuccessfulResult(start_result)) { |
| 260 StopModels(); | 265 StopModels(); |
| 261 if (start_result == ASSOCIATION_FAILED) { | 266 if (start_result == ASSOCIATION_FAILED) { |
| 262 state_ = DISABLED; | 267 state_ = DISABLED; |
| 263 } else { | 268 } else { |
| 264 state_ = NOT_RUNNING; | 269 state_ = NOT_RUNNING; |
| 265 } | 270 } |
| 266 RecordStartFailure(start_result); | 271 RecordStartFailure(start_result); |
| 267 | 272 |
| 268 if (shared_change_processor_.get()) { | 273 if (shared_change_processor_.get()) { |
| 269 shared_change_processor_->Disconnect(); | 274 shared_change_processor_->Disconnect(); |
| 270 shared_change_processor_ = NULL; | 275 shared_change_processor_ = NULL; |
| 271 } | 276 } |
| 272 } | 277 } |
| 273 | 278 |
| 274 start_callback_.Run(start_result, local_merge_result, syncer_merge_result); | 279 start_callback_.Run(start_result, local_merge_result, syncer_merge_result); |
| 275 } | 280 } |
| 276 | 281 |
| 277 void UIDataTypeController::Stop() { | 282 void UIDataTypeController::Stop() { |
| 278 DCHECK(CalledOnValidThread()); | 283 DCHECK(CalledOnValidThread()); |
| 279 DCHECK(IsRealDataType(type())); | 284 DCHECK(syncer::IsRealDataType(type())); |
| 280 | 285 |
| 281 if (state_ == NOT_RUNNING) | 286 if (state_ == NOT_RUNNING) |
| 282 return; | 287 return; |
| 283 | 288 |
| 284 State prev_state = state_; | 289 State prev_state = state_; |
| 285 state_ = STOPPING; | 290 state_ = STOPPING; |
| 286 | 291 |
| 287 if (shared_change_processor_.get()) { | 292 if (shared_change_processor_.get()) { |
| 288 shared_change_processor_->Disconnect(); | 293 shared_change_processor_->Disconnect(); |
| 289 shared_change_processor_ = NULL; | 294 shared_change_processor_ = NULL; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 304 local_service_->StopSyncing(type()); | 309 local_service_->StopSyncing(type()); |
| 305 } | 310 } |
| 306 | 311 |
| 307 state_ = NOT_RUNNING; | 312 state_ = NOT_RUNNING; |
| 308 } | 313 } |
| 309 | 314 |
| 310 void UIDataTypeController::StopModels() { | 315 void UIDataTypeController::StopModels() { |
| 311 // Do nothing by default. | 316 // Do nothing by default. |
| 312 } | 317 } |
| 313 | 318 |
| 314 ModelSafeGroup UIDataTypeController::model_safe_group() const { | 319 syncer::ModelSafeGroup UIDataTypeController::model_safe_group() const { |
| 315 DCHECK(IsRealDataType(type())); | 320 DCHECK(syncer::IsRealDataType(type())); |
| 316 return GROUP_UI; | 321 return syncer::GROUP_UI; |
| 317 } | 322 } |
| 318 | 323 |
| 319 std::string UIDataTypeController::name() const { | 324 std::string UIDataTypeController::name() const { |
| 320 // For logging only. | 325 // For logging only. |
| 321 return ModelTypeToString(type()); | 326 return syncer::ModelTypeToString(type()); |
| 322 } | 327 } |
| 323 | 328 |
| 324 DataTypeController::State UIDataTypeController::state() const { | 329 DataTypeController::State UIDataTypeController::state() const { |
| 325 return state_; | 330 return state_; |
| 326 } | 331 } |
| 327 | 332 |
| 328 std::unique_ptr<DataTypeErrorHandler> | 333 std::unique_ptr<syncer::DataTypeErrorHandler> |
| 329 UIDataTypeController::CreateErrorHandler() { | 334 UIDataTypeController::CreateErrorHandler() { |
| 330 DCHECK(CalledOnValidThread()); | 335 DCHECK(CalledOnValidThread()); |
| 331 return base::MakeUnique<DataTypeErrorHandlerImpl>( | 336 return base::MakeUnique<syncer::DataTypeErrorHandlerImpl>( |
| 332 base::ThreadTaskRunnerHandle::Get(), dump_stack_, | 337 base::ThreadTaskRunnerHandle::Get(), dump_stack_, |
| 333 base::Bind(&UIDataTypeController::OnUnrecoverableError, | 338 base::Bind(&UIDataTypeController::OnUnrecoverableError, |
| 334 base::AsWeakPtr(this))); | 339 base::AsWeakPtr(this))); |
| 335 } | 340 } |
| 336 | 341 |
| 337 void UIDataTypeController::OnUnrecoverableError(const SyncError& error) { | 342 void UIDataTypeController::OnUnrecoverableError( |
| 343 const syncer::SyncError& error) { |
| 338 DCHECK(CalledOnValidThread()); | 344 DCHECK(CalledOnValidThread()); |
| 339 DCHECK_EQ(type(), error.model_type()); | 345 DCHECK_EQ(type(), error.model_type()); |
| 340 if (!model_load_callback_.is_null()) { | 346 if (!model_load_callback_.is_null()) { |
| 341 model_load_callback_.Run(type(), error); | 347 model_load_callback_.Run(type(), error); |
| 342 } | 348 } |
| 343 } | 349 } |
| 344 | 350 |
| 345 void UIDataTypeController::RecordAssociationTime(base::TimeDelta time) { | 351 void UIDataTypeController::RecordAssociationTime(base::TimeDelta time) { |
| 346 DCHECK(CalledOnValidThread()); | 352 DCHECK(CalledOnValidThread()); |
| 347 #define PER_DATA_TYPE_MACRO(type_str) \ | 353 #define PER_DATA_TYPE_MACRO(type_str) \ |
| 348 UMA_HISTOGRAM_TIMES("Sync." type_str "AssociationTime", time); | 354 UMA_HISTOGRAM_TIMES("Sync." type_str "AssociationTime", time); |
| 349 SYNC_DATA_TYPE_HISTOGRAM(type()); | 355 SYNC_DATA_TYPE_HISTOGRAM(type()); |
| 350 #undef PER_DATA_TYPE_MACRO | 356 #undef PER_DATA_TYPE_MACRO |
| 351 } | 357 } |
| 352 | 358 |
| 353 void UIDataTypeController::RecordStartFailure(ConfigureResult result) { | 359 void UIDataTypeController::RecordStartFailure(ConfigureResult result) { |
| 354 DCHECK(CalledOnValidThread()); | 360 DCHECK(CalledOnValidThread()); |
| 355 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures", | 361 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures", |
| 356 ModelTypeToHistogramInt(type()), MODEL_TYPE_COUNT); | 362 ModelTypeToHistogramInt(type()), |
| 363 syncer::MODEL_TYPE_COUNT); |
| 357 #define PER_DATA_TYPE_MACRO(type_str) \ | 364 #define PER_DATA_TYPE_MACRO(type_str) \ |
| 358 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \ | 365 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \ |
| 359 MAX_CONFIGURE_RESULT); | 366 MAX_CONFIGURE_RESULT); |
| 360 SYNC_DATA_TYPE_HISTOGRAM(type()); | 367 SYNC_DATA_TYPE_HISTOGRAM(type()); |
| 361 #undef PER_DATA_TYPE_MACRO | 368 #undef PER_DATA_TYPE_MACRO |
| 362 } | 369 } |
| 363 | 370 |
| 364 } // namespace syncer | 371 } // namespace sync_driver |
| OLD | NEW |