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 3 // found in the LICENSE file. 4 5 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" 6 7 #include "chrome/browser/sync/glue/data_type_controller.h" 8 #include "sync/internal_api/public/base/model_type.h" 9 #include "sync/util/data_type_histogram.h" 10 11 namespace browser_sync { 12 13 bool DataTypeController::IsUnrecoverableResult(StartResult result) { 14 return (result == UNRECOVERABLE_ERROR); 15 } 16 17 bool DataTypeController::IsSuccessfulResult(StartResult result) { 18 return (result == OK || result == OK_FIRST_RUN); 19 } 20 21 syncer::SyncError DataTypeController::CreateAndUploadError( 22 const tracked_objects::Location& location, 23 const std::string& message, 24 syncer::ModelType type) { 25 ChromeReportUnrecoverableError(); 26 return syncer::SyncError(location, 27 syncer::SyncError::DATATYPE_ERROR, 28 message, 29 type); 30 } 31 32 void DataTypeController::RecordUnrecoverableError( 33 const tracked_objects::Location& from_here, 34 const std::string& message) { 35 DVLOG(1) << "Datatype Controller failed for type " 36 << ModelTypeToString(type()) << " " 37 << message << " at location " 38 << from_here.ToString(); 39 UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeRunFailures", 40 ModelTypeToHistogramInt(type()), 41 syncer::MODEL_TYPE_COUNT); 42 43 // TODO(sync): remove this once search engines triggers less errors, such as 44 // due to crbug.com/130448. 45 if (type() != syncer::SEARCH_ENGINES) 46 ChromeReportUnrecoverableError(); 47 } 48 49 } // namespace browser_sync 50