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

Unified Diff: components/sync_driver/fake_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 compile 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: components/sync_driver/fake_data_type_controller.cc
diff --git a/components/sync_driver/fake_data_type_controller.cc b/components/sync_driver/fake_data_type_controller.cc
index 1aeb0fb0853c83676443d91f7201e2ef23748bed..5ba1c4cbdd1f47db80ab8563fa7340a87a15ee79 100644
--- a/components/sync_driver/fake_data_type_controller.cc
+++ b/components/sync_driver/fake_data_type_controller.cc
@@ -16,7 +16,8 @@ FakeDataTypeController::FakeDataTypeController(ModelType type)
DisableTypeCallback()),
state_(NOT_RUNNING),
model_load_delayed_(false),
- type_(type) {}
+ type_(type),
+ ready_for_start_(true) {}
FakeDataTypeController::~FakeDataTypeController() {
}
@@ -54,7 +55,7 @@ void FakeDataTypeController::StartAssociating(
// MODEL_STARTING | ASSOCIATING -> RUNNING | DISABLED | NOT_RUNNING
// (depending on |result|)
-void FakeDataTypeController::FinishStart(StartResult result) {
+void FakeDataTypeController::FinishStart(ConfigureResult result) {
// We should have a callback from Start().
if (last_start_callback_.is_null()) {
ADD_FAILURE();
@@ -73,6 +74,13 @@ void FakeDataTypeController::FinishStart(StartResult result) {
syncer::SyncError::DATATYPE_ERROR,
"Association failed",
type()));
+ } else if (result == UNRECOVERABLE_ERROR) {
+ state_ = NOT_RUNNING;
+ local_merge_result.set_error(
+ syncer::SyncError(FROM_HERE,
+ syncer::SyncError::UNRECOVERABLE_ERROR,
+ "Unrecoverable error",
+ type()));
} else {
state_ = NOT_RUNNING;
local_merge_result.set_error(
@@ -81,15 +89,12 @@ void FakeDataTypeController::FinishStart(StartResult result) {
"Fake error",
type()));
}
- StartCallback start_callback = last_start_callback_;
- last_start_callback_.Reset();
- start_callback.Run(result,
- local_merge_result,
- syncer_merge_result);
+ last_start_callback_.Run(result, local_merge_result, syncer_merge_result);
}
// * -> NOT_RUNNING
void FakeDataTypeController::Stop() {
+ DataTypeController::State old_state = state_;
state_ = NOT_RUNNING;
if (!model_load_callback_.is_null()) {
// Real data type controllers run the callback and specify "ABORTED" as an
@@ -99,7 +104,7 @@ void FakeDataTypeController::Stop() {
}
// The DTM still expects |last_start_callback_| to be called back.
- if (!last_start_callback_.is_null()) {
+ if (old_state != NOT_RUNNING && !last_start_callback_.is_null()) {
syncer::SyncError error(FROM_HERE,
syncer::SyncError::DATATYPE_ERROR,
"Fake error",
@@ -135,7 +140,16 @@ DataTypeController::State FakeDataTypeController::state() const {
void FakeDataTypeController::OnSingleDatatypeUnrecoverableError(
const tracked_objects::Location& from_here,
const std::string& message) {
- ADD_FAILURE() << message;
+ syncer::SyncError error(
+ from_here, syncer::SyncError::DATATYPE_ERROR, message, type_);
+ syncer::SyncMergeResult local_merge_result(type());
+ local_merge_result.set_error(error);
+ last_start_callback_.Run(
+ RUNTIME_ERROR, local_merge_result, syncer::SyncMergeResult(type_));
+}
+
+bool FakeDataTypeController::ReadyForStart() const {
+ return ready_for_start_;
}
void FakeDataTypeController::SetDelayModelLoad() {
@@ -152,4 +166,8 @@ void FakeDataTypeController::SimulateModelLoadFinishing() {
model_load_callback_.Reset();
}
+void FakeDataTypeController::SetReadyForStart(bool ready) {
+ ready_for_start_ = ready;
+}
+
} // namespace sync_driver
« no previous file with comments | « components/sync_driver/fake_data_type_controller.h ('k') | components/sync_driver/model_association_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698