Index: trunk/src/components/sync_driver/fake_data_type_controller.cc |
=================================================================== |
--- trunk/src/components/sync_driver/fake_data_type_controller.cc (revision 289352) |
+++ trunk/src/components/sync_driver/fake_data_type_controller.cc (working copy) |
@@ -16,7 +16,8 @@ |
DisableTypeCallback()), |
state_(NOT_RUNNING), |
model_load_delayed_(false), |
- type_(type) {} |
+ type_(type), |
+ ready_for_start_(true) {} |
FakeDataTypeController::~FakeDataTypeController() { |
} |
@@ -54,7 +55,7 @@ |
// 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 @@ |
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 @@ |
"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 @@ |
} |
// 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,9 +140,18 @@ |
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() { |
model_load_delayed_ = true; |
} |
@@ -152,4 +166,8 @@ |
model_load_callback_.Reset(); |
} |
+void FakeDataTypeController::SetReadyForStart(bool ready) { |
+ ready_for_start_ = ready; |
+} |
+ |
} // namespace sync_driver |