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

Unified Diff: trunk/src/components/sync_driver/non_ui_data_type_controller.cc

Issue 468643002: Revert 288464 "[Sync] Cleanup datatype configuration error handl..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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: trunk/src/components/sync_driver/non_ui_data_type_controller.cc
===================================================================
--- trunk/src/components/sync_driver/non_ui_data_type_controller.cc (revision 289114)
+++ trunk/src/components/sync_driver/non_ui_data_type_controller.cc (working copy)
@@ -111,8 +111,11 @@
void NonUIDataTypeController::Stop() {
DCHECK(ui_thread_->BelongsToCurrentThread());
- if (state() == NOT_RUNNING)
+ if (state() == NOT_RUNNING) {
+ // Stop() should never be called for datatypes that are already stopped.
+ NOTREACHED();
return;
+ }
// Disconnect the change processor. At this point, the
// syncer::SyncableService can no longer interact with the Syncer, even if
@@ -172,6 +175,9 @@
// 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,
@@ -187,7 +193,7 @@
NonUIDataTypeController::~NonUIDataTypeController() {}
void NonUIDataTypeController::StartDone(
- DataTypeController::ConfigureResult start_result,
+ DataTypeController::StartResult start_result,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result) {
DCHECK(!ui_thread_->BelongsToCurrentThread());
@@ -209,7 +215,7 @@
}
void NonUIDataTypeController::StartDoneImpl(
- DataTypeController::ConfigureResult start_result,
+ DataTypeController::StartResult start_result,
DataTypeController::State new_state,
const syncer::SyncMergeResult& local_merge_result,
const syncer::SyncMergeResult& syncer_merge_result) {
@@ -226,6 +232,7 @@
// (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;
}
@@ -236,7 +243,12 @@
RecordStartFailure(start_result);
}
- start_callback_.Run(start_result, local_merge_result, syncer_merge_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);
}
void NonUIDataTypeController::RecordAssociationTime(base::TimeDelta time) {
@@ -247,7 +259,7 @@
#undef PER_DATA_TYPE_MACRO
}
-void NonUIDataTypeController::RecordStartFailure(ConfigureResult result) {
+void NonUIDataTypeController::RecordStartFailure(StartResult result) {
DCHECK(ui_thread_->BelongsToCurrentThread());
UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures",
ModelTypeToHistogramInt(type()),
@@ -275,18 +287,8 @@
const tracked_objects::Location& from_here,
const std::string& message) {
DCHECK(ui_thread_->BelongsToCurrentThread());
- 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()));
- }
+ if (!disable_callback().is_null())
+ disable_callback().Run(from_here, message);
}
bool NonUIDataTypeController::StartAssociationAsync() {
@@ -346,11 +348,6 @@
}
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