Index: sync/sessions/sync_session.cc |
diff --git a/sync/sessions/sync_session.cc b/sync/sessions/sync_session.cc |
index 85ac8ccd7b72b6785191bc3915ae544f96420bd4..fc014fa7598d40051d5d33a92ddc889cc0e0eb5f 100644 |
--- a/sync/sessions/sync_session.cc |
+++ b/sync/sessions/sync_session.cc |
@@ -59,7 +59,8 @@ SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate, |
delegate_(delegate), |
workers_(workers), |
routing_info_(routing_info), |
- enabled_groups_(ComputeEnabledGroups(routing_info_, workers_)) { |
+ enabled_groups_(ComputeEnabledGroups(routing_info_, workers_)), |
+ finished_(false) { |
status_controller_.reset(new StatusController(routing_info_)); |
std::sort(workers_.begin(), workers_.end()); |
} |
@@ -226,21 +227,39 @@ namespace { |
// successfully. |
// |
bool IsError(SyncerError error) { |
- return error != UNSET |
- && error != SYNCER_OK; |
+ return error != UNSET && error != SYNCER_OK; |
} |
-} // namespace |
-bool SyncSession::Succeeded() const { |
+// Returns false iff one of the command results had an error. |
+bool HadErrors(const ErrorCounters& error) { |
const bool download_updates_error = |
- IsError(status_controller_->error().last_download_updates_result); |
- const bool post_commit_error = |
- IsError(status_controller_->error().last_post_commit_result); |
+ IsError(error.last_download_updates_result); |
+ const bool post_commit_error = IsError(error.last_post_commit_result); |
const bool process_commit_response_error = |
- IsError(status_controller_->error().last_process_commit_response_result); |
- return !download_updates_error |
- && !post_commit_error |
- && !process_commit_response_error; |
+ IsError(error.last_process_commit_response_result); |
+ return download_updates_error || |
+ post_commit_error || |
+ process_commit_response_error; |
+} |
+} // namespace |
+ |
+bool SyncSession::Succeeded() const { |
+ const ErrorCounters& error = status_controller_->error(); |
+ return finished_ && !HadErrors(error); |
+} |
+ |
+bool SyncSession::SuccessfullyReachServer() const { |
+ const ErrorCounters& error = status_controller_->error(); |
+ bool reach_server = false; |
+ if (error.last_download_updates_result == SYNCER_OK || |
+ error.last_post_commit_result == SYNCER_OK || |
+ error.last_process_commit_response_result == SYNCER_OK) |
+ reach_server = true; |
+ return reach_server && !HadErrors(error); |
+} |
+ |
+void SyncSession::SetFinished() { |
+ finished_ = true; |
} |
} // namespace sessions |