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