Index: chrome/browser/sync/sessions/sync_session.cc |
diff --git a/chrome/browser/sync/sessions/sync_session.cc b/chrome/browser/sync/sessions/sync_session.cc |
index 064fef6744e9d753fbb4b2e58975646e16ab9190..fe164e468120a702326ee7aa0d06f462e7f71678 100644 |
--- a/chrome/browser/sync/sessions/sync_session.cc |
+++ b/chrome/browser/sync/sessions/sync_session.cc |
@@ -233,6 +233,83 @@ std::set<ModelSafeGroup> |
return enabled_groups_with_verified_updates; |
} |
+namespace { |
+// Returns true if the result indicates an error that might go away on its own. |
+// In other words, it wouldn't be a bad idea to retry with exponential backoff |
+// if we detect one of these errors. |
+bool IsTransientError(SyncerError error) { |
+ switch (error) { |
+ // No operation was not attempted. |
+ case UNINITIALIZED: |
+ return false; |
+ |
+ // Client-side error. |
+ case DIRECTORY_LOOKUP_FAILED: |
+ return false; |
+ |
+ // Probably temporary network issues. |
+ case NETWORK_CONNECTION_UNAVAILABLE: |
+ case NETWORK_IO_ERROR: |
+ return true; |
+ |
+ // Error cause is ambiguous. It's best not to retry in these cases. |
+ case SYNC_SERVER_ERROR: |
+ case SERVER_RETURN_UNKNOWN_ERROR: |
+ return false; |
+ |
+ // These require user intervention |
+ case SYNC_AUTH_ERROR: |
+ case SERVER_RETURN_INVALID_CREDENTIAL: |
+ return false; |
+ |
+ // We have special logic to handle backoff in this case. |
+ case SERVER_RETURN_THROTTLED: |
+ return false; |
+ |
+ // The server wants us to retry. |
+ case SERVER_RETURN_TRANSIENT_ERROR: |
+ return true; |
+ |
+ // Handled separately. |
+ case SERVER_RETURN_MIGRATION_DONE: |
+ case SERVER_RETURN_CLEAR_PENDING: |
+ case SERVER_RETURN_NOT_MY_BIRTHDAY: |
+ case SERVER_RESPONSE_VALIDATION_FAILED: |
+ return false; |
+ |
+ case NO_ERROR: |
+ return false; |
+ } |
+} |
+} // namespace |
+ |
+bool SyncSession::ExperiencedTransientError() const { |
+ return IsTransientError(status_controller_->error().download_updates_result) |
+ || IsTransientError(status_controller_->error().post_commit_result) |
+ || IsTransientError( |
+ status_controller_->error().process_commit_response_result); |
+} |
+ |
+namespace { |
+// Return true if the command in question was attempted and did not complete |
+// successfully. |
+// |
+bool IsError(SyncerError error) { |
+ return error != UNINITIALIZED && error != NO_ERROR; |
+} |
+} // namespace |
+ |
+bool SyncSession::Succeeded() const { |
+ bool download_updates_error = |
+ IsError(status_controller_->error().download_updates_result); |
+ bool post_commit_error = |
+ IsError(status_controller_->error().post_commit_result); |
+ bool process_commit_response_error = |
+ IsError(status_controller_->error().process_commit_response_result); |
+ return !download_updates_error |
+ && !post_commit_error |
+ && !process_commit_response_error; |
+} |
} // namespace sessions |
} // namespace browser_sync |