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

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

Issue 7453014: [Sync] Refactor sync datatype error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 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: 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 5200f5d897d3add1f3a57108fdd3b22987a919f7..96d6843ea4c712dc0da50848c79dee9647f64d20 100644
--- a/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
+++ b/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sync/api/sync_error.h"
#include "chrome/browser/sync/glue/change_processor.h"
#include "chrome/browser/sync/glue/model_associator.h"
#include "chrome/browser/sync/profile_sync_factory.h"
@@ -104,10 +105,11 @@ void NonFrontendDataTypeController::StartAssociation() {
}
base::TimeTicks start_time = base::TimeTicks::Now();
- bool merge_success = model_associator_->AssociateModels();
+ SyncError error;
+ bool merge_success = model_associator_->AssociateModels(&error);
RecordAssociationTime(base::TimeTicks::Now() - start_time);
if (!merge_success) {
- StartFailed(ASSOCIATION_FAILED, FROM_HERE);
+ StartFailed(ASSOCIATION_FAILED, error.location());
return;
}
@@ -115,11 +117,13 @@ void NonFrontendDataTypeController::StartAssociation() {
StartDone(!sync_has_nodes ? OK_FIRST_RUN : OK, RUNNING, FROM_HERE);
}
-void NonFrontendDataTypeController::StartFailed(StartResult result,
+void NonFrontendDataTypeController::StartFailed(
+ StartResult result,
const tracked_objects::Location& location) {
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
model_associator_.reset();
change_processor_.reset();
+ // TODO(zea): Send the full SyncError on failure and handle it higher up.
StartDone(result, NOT_RUNNING, location);
}
@@ -216,8 +220,10 @@ void NonFrontendDataTypeController::StopModels() {
void NonFrontendDataTypeController::StopAssociation() {
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (model_associator_.get())
- model_associator_->DisassociateModels();
+ if (model_associator_.get()) {
+ SyncError error;
+ model_associator_->DisassociateModels(&error);
+ }
model_associator_.reset();
change_processor_.reset();
datatype_stopped_.Signal();
@@ -237,7 +243,7 @@ void NonFrontendDataTypeController::OnUnrecoverableError(
const std::string& message) {
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
RecordUnrecoverableError(from_here, message);
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod(this,
+ BrowserThread::PostTask(BrowserThread::UI, from_here, NewRunnableMethod(this,
&NonFrontendDataTypeController::OnUnrecoverableErrorImpl, from_here,
message));
}

Powered by Google App Engine
This is Rietveld 408576698