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

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

Issue 465113002: Revert 288557 "[Sync] Use OnSingleDataTypeUnrecoverableError for..." (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/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
===================================================================
--- trunk/src/chrome/browser/sync/glue/non_frontend_data_type_controller.cc (revision 289111)
+++ trunk/src/chrome/browser/sync/glue/non_frontend_data_type_controller.cc (working copy)
@@ -157,15 +157,16 @@
NonFrontendDataTypeController::AssociationResult::~AssociationResult() {}
// TODO(tim): Legacy controllers are being left behind in componentization
-// effort for now, hence still having a dependency on ProfileSyncService.
-// That dep can probably be removed without too much work.
+// effort for now, hence passing null DisableTypeCallback and 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),
+ : DataTypeController(ui_thread, error_callback, DisableTypeCallback()),
state_(NOT_RUNNING),
profile_sync_factory_(profile_sync_factory),
profile_(profile),
@@ -252,10 +253,8 @@
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
// processor and associator on backend. Otherwise it could crash if syncer
@@ -298,19 +297,21 @@
return state_;
}
-void NonFrontendDataTypeController::OnSingleDataTypeUnrecoverableError(
- const syncer::SyncError& error) {
+void NonFrontendDataTypeController::OnSingleDatatypeUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
DCHECK(IsOnBackendThread());
- DCHECK_EQ(type(), error.model_type());
- RecordUnrecoverableError(error.location(), error.message());
- BrowserThread::PostTask(BrowserThread::UI, error.location(),
+ RecordUnrecoverableError(from_here, message);
+ BrowserThread::PostTask(BrowserThread::UI, from_here,
base::Bind(&NonFrontendDataTypeController::DisableImpl,
this,
- error));
+ from_here,
+ message));
}
NonFrontendDataTypeController::NonFrontendDataTypeController()
- : DataTypeController(base::MessageLoopProxy::current(), base::Closure()),
+ : DataTypeController(base::MessageLoopProxy::current(), base::Closure(),
+ DisableTypeCallback()),
state_(NOT_RUNNING),
profile_sync_factory_(NULL),
profile_(NULL),
@@ -370,19 +371,22 @@
RecordStartFailure(start_result);
}
- start_callback_.Run(start_result, local_merge_result, syncer_merge_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);
}
void NonFrontendDataTypeController::DisableImpl(
- const syncer::SyncError& error) {
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- 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()));
- }
+ syncer::SyncError error(
+ from_here, syncer::SyncError::DATATYPE_ERROR, message, type());
+ profile_sync_service_->DisableDatatype(error);
}
void NonFrontendDataTypeController::RecordAssociationTime(

Powered by Google App Engine
This is Rietveld 408576698