| 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 "base/location.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 9 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 11 #include "components/sync_driver/generic_change_processor_factory.h" | 13 #include "components/sync_driver/generic_change_processor_factory.h" |
| 12 #include "components/sync_driver/shared_change_processor_ref.h" | 14 #include "components/sync_driver/shared_change_processor_ref.h" |
| 13 #include "sync/api/sync_error.h" | 15 #include "sync/api/sync_error.h" |
| 14 #include "sync/api/syncable_service.h" | 16 #include "sync/api/syncable_service.h" |
| 15 #include "sync/internal_api/public/base/model_type.h" | 17 #include "sync/internal_api/public/base/model_type.h" |
| 16 #include "sync/util/data_type_histogram.h" | 18 #include "sync/util/data_type_histogram.h" |
| 17 | 19 |
| 18 namespace sync_driver { | 20 namespace sync_driver { |
| 19 | 21 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 93 } |
| 92 | 94 |
| 93 void UIDataTypeController::StartAssociating( | 95 void UIDataTypeController::StartAssociating( |
| 94 const StartCallback& start_callback) { | 96 const StartCallback& start_callback) { |
| 95 DCHECK(ui_thread_->BelongsToCurrentThread()); | 97 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 96 DCHECK(!start_callback.is_null()); | 98 DCHECK(!start_callback.is_null()); |
| 97 DCHECK_EQ(state_, MODEL_LOADED); | 99 DCHECK_EQ(state_, MODEL_LOADED); |
| 98 | 100 |
| 99 start_callback_ = start_callback; | 101 start_callback_ = start_callback; |
| 100 state_ = ASSOCIATING; | 102 state_ = ASSOCIATING; |
| 101 base::MessageLoop::current()->PostTask( | 103 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 102 FROM_HERE, base::Bind(&UIDataTypeController::Associate, this)); | 104 FROM_HERE, base::Bind(&UIDataTypeController::Associate, this)); |
| 103 } | 105 } |
| 104 | 106 |
| 105 bool UIDataTypeController::StartModels() { | 107 bool UIDataTypeController::StartModels() { |
| 106 DCHECK_EQ(state_, MODEL_STARTING); | 108 DCHECK_EQ(state_, MODEL_STARTING); |
| 107 // By default, no additional services need to be started before we can proceed | 109 // By default, no additional services need to be started before we can proceed |
| 108 // with model association. | 110 // with model association. |
| 109 return true; | 111 return true; |
| 110 } | 112 } |
| 111 | 113 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 void UIDataTypeController::OnSingleDataTypeUnrecoverableError( | 359 void UIDataTypeController::OnSingleDataTypeUnrecoverableError( |
| 358 const syncer::SyncError& error) { | 360 const syncer::SyncError& error) { |
| 359 DCHECK_EQ(type(), error.model_type()); | 361 DCHECK_EQ(type(), error.model_type()); |
| 360 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeRunFailures", | 362 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeRunFailures", |
| 361 ModelTypeToHistogramInt(type()), | 363 ModelTypeToHistogramInt(type()), |
| 362 syncer::MODEL_TYPE_COUNT); | 364 syncer::MODEL_TYPE_COUNT); |
| 363 // TODO(tim): We double-upload some errors. See bug 383480. | 365 // TODO(tim): We double-upload some errors. See bug 383480. |
| 364 if (!error_callback_.is_null()) | 366 if (!error_callback_.is_null()) |
| 365 error_callback_.Run(); | 367 error_callback_.Run(); |
| 366 if (!model_load_callback_.is_null()) { | 368 if (!model_load_callback_.is_null()) { |
| 367 base::MessageLoop::current()->PostTask( | 369 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 368 FROM_HERE, base::Bind(model_load_callback_, type(), error)); | 370 FROM_HERE, base::Bind(model_load_callback_, type(), error)); |
| 369 } | 371 } |
| 370 } | 372 } |
| 371 | 373 |
| 372 void UIDataTypeController::RecordAssociationTime(base::TimeDelta time) { | 374 void UIDataTypeController::RecordAssociationTime(base::TimeDelta time) { |
| 373 DCHECK(ui_thread_->BelongsToCurrentThread()); | 375 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 374 #define PER_DATA_TYPE_MACRO(type_str) \ | 376 #define PER_DATA_TYPE_MACRO(type_str) \ |
| 375 UMA_HISTOGRAM_TIMES("Sync." type_str "AssociationTime", time); | 377 UMA_HISTOGRAM_TIMES("Sync." type_str "AssociationTime", time); |
| 376 SYNC_DATA_TYPE_HISTOGRAM(type()); | 378 SYNC_DATA_TYPE_HISTOGRAM(type()); |
| 377 #undef PER_DATA_TYPE_MACRO | 379 #undef PER_DATA_TYPE_MACRO |
| 378 } | 380 } |
| 379 | 381 |
| 380 void UIDataTypeController::RecordStartFailure(ConfigureResult result) { | 382 void UIDataTypeController::RecordStartFailure(ConfigureResult result) { |
| 381 DCHECK(ui_thread_->BelongsToCurrentThread()); | 383 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 382 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures", | 384 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures", |
| 383 ModelTypeToHistogramInt(type()), | 385 ModelTypeToHistogramInt(type()), |
| 384 syncer::MODEL_TYPE_COUNT); | 386 syncer::MODEL_TYPE_COUNT); |
| 385 #define PER_DATA_TYPE_MACRO(type_str) \ | 387 #define PER_DATA_TYPE_MACRO(type_str) \ |
| 386 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \ | 388 UMA_HISTOGRAM_ENUMERATION("Sync." type_str "ConfigureFailure", result, \ |
| 387 MAX_CONFIGURE_RESULT); | 389 MAX_CONFIGURE_RESULT); |
| 388 SYNC_DATA_TYPE_HISTOGRAM(type()); | 390 SYNC_DATA_TYPE_HISTOGRAM(type()); |
| 389 #undef PER_DATA_TYPE_MACRO | 391 #undef PER_DATA_TYPE_MACRO |
| 390 } | 392 } |
| 391 | 393 |
| 392 } // namespace sync_driver | 394 } // namespace sync_driver |
| OLD | NEW |