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

Unified Diff: chrome/browser/sync/glue/non_frontend_data_type_controller.cc

Issue 436733002: [Sync] Use OnSingleDataTypeUnrecoverableError for all errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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: chrome/browser/sync/glue/non_frontend_data_type_controller.cc
diff --git a/chrome/browser/sync/glue/non_frontend_data_type_controller.cc b/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
index 5b83a8e7d52e1cd5135baf1cf7c1f8d764b41859..ea9d144851ef6c5d17b510f0e2d53757a36ab343 100644
--- a/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
+++ b/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
@@ -157,16 +157,15 @@ NonFrontendDataTypeController::AssociationResult::AssociationResult(
NonFrontendDataTypeController::AssociationResult::~AssociationResult() {}
// TODO(tim): Legacy controllers are being left behind in componentization
-// effort for now, hence passing null DisableTypeCallback and still having
-// a dependency on ProfileSyncService. That dep can probably be removed
-// without too much work.
+// effort for now, hence still having a dependency on ProfileSyncService.
+// That dep can probably be removed without too much work.
NonFrontendDataTypeController::NonFrontendDataTypeController(
scoped_refptr<base::MessageLoopProxy> ui_thread,
const base::Closure& error_callback,
ProfileSyncComponentsFactory* profile_sync_factory,
Profile* profile,
ProfileSyncService* sync_service)
- : DataTypeController(ui_thread, error_callback, DisableTypeCallback()),
+ : DataTypeController(ui_thread, error_callback),
state_(NOT_RUNNING),
profile_sync_factory_(profile_sync_factory),
profile_(profile),
@@ -253,7 +252,9 @@ void DestroyComponentsInBackend(
void NonFrontendDataTypeController::Stop() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK_NE(state_, NOT_RUNNING);
+
+ if (state_ == NOT_RUNNING)
+ return;
// Deactivate the date type on the UI thread first to stop processing
// sync server changes. This needs to happen before posting task to destroy
@@ -297,21 +298,19 @@ sync_driver::DataTypeController::State NonFrontendDataTypeController::state()
return state_;
}
-void NonFrontendDataTypeController::OnSingleDatatypeUnrecoverableError(
- const tracked_objects::Location& from_here,
- const std::string& message) {
+void NonFrontendDataTypeController::OnSingleDataTypeUnrecoverableError(
+ const syncer::SyncError& error) {
DCHECK(IsOnBackendThread());
- RecordUnrecoverableError(from_here, message);
- BrowserThread::PostTask(BrowserThread::UI, from_here,
+ DCHECK_EQ(type(), error.model_type());
+ RecordUnrecoverableError(error.location(), error.message());
+ BrowserThread::PostTask(BrowserThread::UI, error.location(),
base::Bind(&NonFrontendDataTypeController::DisableImpl,
this,
- from_here,
- message));
+ error));
}
NonFrontendDataTypeController::NonFrontendDataTypeController()
- : DataTypeController(base::MessageLoopProxy::current(), base::Closure(),
- DisableTypeCallback()),
+ : DataTypeController(base::MessageLoopProxy::current(), base::Closure()),
state_(NOT_RUNNING),
profile_sync_factory_(NULL),
profile_(NULL),
@@ -371,22 +370,19 @@ void NonFrontendDataTypeController::StartDoneImpl(
RecordStartFailure(start_result);
}
- DCHECK(!start_callback_.is_null());
- // 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 NonFrontendDataTypeController::DisableImpl(
- const tracked_objects::Location& from_here,
- const std::string& message) {
+ const syncer::SyncError& error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- syncer::SyncError error(
- from_here, syncer::SyncError::DATATYPE_ERROR, message, type());
- profile_sync_service_->DisableDatatype(error);
+ if (!start_callback_.is_null()) {
+ syncer::SyncMergeResult local_merge_result(type());
+ local_merge_result.set_error(error);
+ start_callback_.Run(RUNTIME_ERROR,
+ local_merge_result,
+ syncer::SyncMergeResult(type()));
+ }
}
void NonFrontendDataTypeController::RecordAssociationTime(

Powered by Google App Engine
This is Rietveld 408576698