| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/api/data_type_error_handler_impl.h" | 5 #include "components/sync/api/data_type_error_handler_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 | 9 |
| 10 namespace syncer { | 10 namespace syncer { |
| 11 | 11 |
| 12 DataTypeErrorHandlerImpl::DataTypeErrorHandlerImpl( | 12 DataTypeErrorHandlerImpl::DataTypeErrorHandlerImpl( |
| 13 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 13 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
| 14 const base::Closure& dump_stack, | 14 const base::Closure& dump_stack, |
| 15 const ErrorCallback& sync_callback) | 15 const ErrorCallback& sync_callback) |
| 16 : ui_thread_(ui_thread), | 16 : ui_thread_(ui_thread), |
| 17 dump_stack_(dump_stack), | 17 dump_stack_(dump_stack), |
| 18 sync_callback_(sync_callback) {} | 18 sync_callback_(sync_callback) {} |
| 19 | 19 |
| 20 DataTypeErrorHandlerImpl::~DataTypeErrorHandlerImpl() {} | 20 DataTypeErrorHandlerImpl::~DataTypeErrorHandlerImpl() {} |
| 21 | 21 |
| 22 void DataTypeErrorHandlerImpl::OnUnrecoverableError(const SyncError& error) { | 22 void DataTypeErrorHandlerImpl::OnUnrecoverableError(const SyncError& error) { |
| 23 if (!dump_stack_.is_null()) | 23 if (!dump_stack_.is_null()) |
| 24 dump_stack_.Run(); | 24 dump_stack_.Run(); |
| 25 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeRunFailures", | 25 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeRunFailures", |
| 26 ModelTypeToHistogramInt(error.model_type()), | 26 ModelTypeToHistogramInt(error.model_type()), |
| 27 syncer::MODEL_TYPE_COUNT); | 27 MODEL_TYPE_COUNT); |
| 28 ui_thread_->PostTask(error.location(), base::Bind(sync_callback_, error)); | 28 ui_thread_->PostTask(error.location(), base::Bind(sync_callback_, error)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 syncer::SyncError DataTypeErrorHandlerImpl::CreateAndUploadError( | 31 SyncError DataTypeErrorHandlerImpl::CreateAndUploadError( |
| 32 const tracked_objects::Location& location, | 32 const tracked_objects::Location& location, |
| 33 const std::string& message, | 33 const std::string& message, |
| 34 syncer::ModelType type) { | 34 ModelType type) { |
| 35 if (!dump_stack_.is_null()) | 35 if (!dump_stack_.is_null()) |
| 36 dump_stack_.Run(); | 36 dump_stack_.Run(); |
| 37 return syncer::SyncError(location, syncer::SyncError::DATATYPE_ERROR, message, | 37 return SyncError(location, SyncError::DATATYPE_ERROR, message, type); |
| 38 type); | |
| 39 } | 38 } |
| 40 | 39 |
| 41 std::unique_ptr<DataTypeErrorHandler> DataTypeErrorHandlerImpl::Copy() const { | 40 std::unique_ptr<DataTypeErrorHandler> DataTypeErrorHandlerImpl::Copy() const { |
| 42 return base::MakeUnique<DataTypeErrorHandlerImpl>(ui_thread_, dump_stack_, | 41 return base::MakeUnique<DataTypeErrorHandlerImpl>(ui_thread_, dump_stack_, |
| 43 sync_callback_); | 42 sync_callback_); |
| 44 } | 43 } |
| 45 | 44 |
| 46 } // namespace syncer | 45 } // namespace syncer |
| OLD | NEW |