Commit a2aecfd5 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Sync::USS] Simplify ClientTagBasedModelTypeProcessor::ReportError()

This CL doesn't introduce any behavioral change. It's a pure
refactoring CL that simplifies the code in ReportError().

Change-Id: I24295b8266d013e639e5a0dd5f5b23a475a5b27d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1588566
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Auto-Submit: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660351}
parent ad1b7911
...@@ -293,8 +293,9 @@ void ClientTagBasedModelTypeProcessor::ReportError(const ModelError& error) { ...@@ -293,8 +293,9 @@ void ClientTagBasedModelTypeProcessor::ReportError(const ModelError& error) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Ignore all errors after the first. // Ignore all errors after the first.
if (model_error_) if (model_error_) {
return; return;
}
model_error_ = error; model_error_ = error;
...@@ -307,14 +308,14 @@ void ClientTagBasedModelTypeProcessor::ReportError(const ModelError& error) { ...@@ -307,14 +308,14 @@ void ClientTagBasedModelTypeProcessor::ReportError(const ModelError& error) {
DisconnectSync(); DisconnectSync();
} }
if (start_callback_) { // Shouldn't connect anymore.
// Tell sync about the error instead of connecting. start_callback_.Reset();
ConnectIfReady(); if (activation_request_.error_handler) {
} else if (activation_request_.error_handler) { // Tell sync about the error.
// Connecting was already initiated; just tell sync about the error instead
// of going through ConnectIfReady().
activation_request_.error_handler.Run(error); activation_request_.error_handler.Run(error);
} }
// If the error handler isn't ready yet, we defer reporting the error until it
// becomes available which happens in ConnectIfReady() upon OnSyncStarting().
} }
base::Optional<ModelError> ClientTagBasedModelTypeProcessor::GetError() const { base::Optional<ModelError> ClientTagBasedModelTypeProcessor::GetError() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment