Commit 5e393214 authored by joedow's avatar joedow Committed by Commit bot

Addressing feedback from ValidatingAuthenticator CL

This change addresses comments left on
https://codereview.chromium.org/2277553002/ after it was checked in.

The comments were around improvements to the switch used to set the
current authenticator state.  I addressed them by removing the default
case (and leaving a comment on why) and moving the success case into the
switch.

BUG=617185

Review-Url: https://codereview.chromium.org/2308133002
Cr-Commit-Position: refs/heads/master@{#416410}
parent 0fce96ca
...@@ -91,18 +91,16 @@ void ValidatingAuthenticator::OnValidateComplete( ...@@ -91,18 +91,16 @@ void ValidatingAuthenticator::OnValidateComplete(
const buzz::XmlElement* message, const buzz::XmlElement* message,
const base::Closure& resume_callback, const base::Closure& resume_callback,
Result validation_result) { Result validation_result) {
if (validation_result == Result::SUCCESS) { // Process the original message in the success case, otherwise map
current_authenticator_->ProcessMessage( // |rejection_reason_| to a known reason, set |state_| to REJECTED and notify
message, base::Bind(&ValidatingAuthenticator::UpdateState, // the listener of the connection error via the callback.
weak_factory_.GetWeakPtr(), resume_callback));
return;
}
// |validation_result| represents a rejected state so map the result to a
// rejection reason and call the callback to let the caller know the result.
state_ = Authenticator::REJECTED;
switch (validation_result) { switch (validation_result) {
case Result::SUCCESS:
current_authenticator_->ProcessMessage(
message, base::Bind(&ValidatingAuthenticator::UpdateState,
weak_factory_.GetWeakPtr(), resume_callback));
return;
case Result::ERROR_INVALID_CREDENTIALS: case Result::ERROR_INVALID_CREDENTIALS:
rejection_reason_ = Authenticator::INVALID_CREDENTIALS; rejection_reason_ = Authenticator::INVALID_CREDENTIALS;
break; break;
...@@ -114,13 +112,9 @@ void ValidatingAuthenticator::OnValidateComplete( ...@@ -114,13 +112,9 @@ void ValidatingAuthenticator::OnValidateComplete(
case Result::ERROR_REJECTED_BY_USER: case Result::ERROR_REJECTED_BY_USER:
rejection_reason_ = Authenticator::REJECTED_BY_USER; rejection_reason_ = Authenticator::REJECTED_BY_USER;
break; break;
default:
// Log an error and fail to prevent logging a misleading error value.
CHECK(false) << "Unknown validation result value: "
<< static_cast<unsigned int>(validation_result);
} }
state_ = Authenticator::REJECTED;
resume_callback.Run(); resume_callback.Run();
} }
......
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