Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: components/sync_driver/non_ui_data_type_controller.cc

Issue 420633002: [Sync] Cleanup datatype configuration error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unready Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/sync_driver/non_ui_data_type_controller.cc
diff --git a/components/sync_driver/non_ui_data_type_controller.cc b/components/sync_driver/non_ui_data_type_controller.cc
index a7dcf26732a3158e012363fed55ad207c87ef40b..73f12bef204835bbb774636657071deee01021c1 100644
--- a/components/sync_driver/non_ui_data_type_controller.cc
+++ b/components/sync_driver/non_ui_data_type_controller.cc
@@ -175,9 +175,6 @@ void NonUIDataTypeController::OnSingleDatatypeUnrecoverableError(
// TODO(tim): We double-upload some errors. See bug 383480.
if (!error_callback_.is_null())
error_callback_.Run();
- UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeRunFailures",
- ModelTypeToHistogramInt(type()),
- syncer::MODEL_TYPE_COUNT);
ui_thread_->PostTask(from_here,
base::Bind(&NonUIDataTypeController::DisableImpl,
this,
@@ -193,7 +190,7 @@ NonUIDataTypeController::NonUIDataTypeController()
NonUIDataTypeController::~NonUIDataTypeController() {}
void NonUIDataTypeController::StartDone(
- DataTypeController::StartResult start_result,
+ DataTypeController::ConfigureResult start_result,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result) {
DCHECK(!ui_thread_->BelongsToCurrentThread());
@@ -215,7 +212,7 @@ void NonUIDataTypeController::StartDone(
}
void NonUIDataTypeController::StartDoneImpl(
- DataTypeController::StartResult start_result,
+ DataTypeController::ConfigureResult start_result,
DataTypeController::State new_state,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result) {
@@ -232,7 +229,6 @@ void NonUIDataTypeController::StartDoneImpl(
// (due to Stop being called) and then posted from the non-UI thread. In
// this case, we drop the second call because we've already been stopped.
if (state_ == NOT_RUNNING) {
- DCHECK(start_callback_.is_null());
return;
}
@@ -243,12 +239,7 @@ void NonUIDataTypeController::StartDoneImpl(
RecordStartFailure(start_result);
}
- // We have to release the callback before we call it, since it's possible
- // invoking the callback will trigger a call to STOP(), which will get
- // confused by the non-NULL start_callback_.
- StartCallback callback = start_callback_;
- start_callback_.Reset();
- callback.Run(start_result, local_merge_result, syncer_merge_result);
+ start_callback_.Run(start_result, local_merge_result, syncer_merge_result);
}
void NonUIDataTypeController::RecordAssociationTime(base::TimeDelta time) {
@@ -259,7 +250,7 @@ void NonUIDataTypeController::RecordAssociationTime(base::TimeDelta time) {
#undef PER_DATA_TYPE_MACRO
}
-void NonUIDataTypeController::RecordStartFailure(StartResult result) {
+void NonUIDataTypeController::RecordStartFailure(ConfigureResult result) {
DCHECK(ui_thread_->BelongsToCurrentThread());
UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures",
ModelTypeToHistogramInt(type()),
@@ -287,8 +278,18 @@ void NonUIDataTypeController::DisableImpl(
const tracked_objects::Location& from_here,
const std::string& message) {
DCHECK(ui_thread_->BelongsToCurrentThread());
- if (!disable_callback().is_null())
- disable_callback().Run(from_here, message);
+ UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeRunFailures",
+ ModelTypeToHistogramInt(type()),
+ syncer::MODEL_TYPE_COUNT);
+ if (!start_callback_.is_null()) {
+ syncer::SyncError error(
+ from_here, syncer::SyncError::DATATYPE_ERROR, message, type());
+ syncer::SyncMergeResult local_merge_result(type());
+ local_merge_result.set_error(error);
+ start_callback_.Run(RUNTIME_ERROR,
+ local_merge_result,
+ syncer::SyncMergeResult(type()));
+ }
}
bool NonUIDataTypeController::StartAssociationAsync() {
@@ -348,6 +349,11 @@ void NonUIDataTypeController::
}
if (!shared_change_processor->CryptoReadyIfNecessary()) {
+ syncer::SyncError error(FROM_HERE,
+ syncer::SyncError::CRYPTO_ERROR,
+ "",
+ type());
+ local_merge_result.set_error(error);
StartDone(NEEDS_CRYPTO,
local_merge_result,
syncer_merge_result);

Powered by Google App Engine
This is Rietveld 408576698