Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: remoting/protocol/jingle_session.cc

Issue 9567033: Cleanup error handling in the client plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/jingle_session.cc
diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc
index 01e12bed85a1d57002691d0bab3b1e570d157a99..aff0d45fbfc87290960147b08280f6312fc2d204 100644
--- a/remoting/protocol/jingle_session.cc
+++ b/remoting/protocol/jingle_session.cc
@@ -38,7 +38,7 @@ const int kTransportInfoSendDelayMs = 2;
// |transport-info|.
const int kMessageResponseTimeoutSeconds = 10;
-Session::Error AuthRejectionReasonToError(
+ErrorCode AuthRejectionReasonToErrorCode(
Authenticator::RejectionReason reason) {
switch (reason) {
case Authenticator::INVALID_CREDENTIALS:
@@ -79,7 +79,7 @@ void JingleSession::SetRouteChangeCallback(
route_change_callback_ = callback;
}
-Session::Error JingleSession::error() {
+ErrorCode JingleSession::error() {
DCHECK(CalledOnValidThread());
return error_;
}
@@ -148,7 +148,7 @@ void JingleSession::AcceptIncomingConnection(
DCHECK_EQ(authenticator_->state(), Authenticator::WAITING_MESSAGE);
authenticator_->ProcessMessage(first_auth_message);
if (authenticator_->state() == Authenticator::REJECTED) {
- CloseInternal(AuthRejectionReasonToError(
+ CloseInternal(AuthRejectionReasonToErrorCode(
authenticator_->rejection_reason()));
return;
}
@@ -290,15 +290,12 @@ void JingleSession::OnMessageResponse(
JingleMessage::ActionType request_type,
IqRequest* request,
const buzz::XmlElement* response) {
- Error error = OK;
-
std::string type_str = JingleMessage::GetActionName(request_type);
+ CleanupPendingRequests(request);
if (!response) {
LOG(ERROR) << type_str << " request timed out.";
- // Most likely the session-initiate timeout indicates a problem
- // with the signaling.
- error = UNKNOWN_ERROR;
+ CloseInternal(SIGNALING_TIMEOUT);
} else {
const std::string& type = response->Attr(buzz::QName("", "type"));
if (type != "result") {
@@ -310,21 +307,16 @@ void JingleSession::OnMessageResponse(
case JingleMessage::SESSION_INFO:
// session-info is used for the new authentication protocol,
// and wasn't previously supported.
- error = INCOMPATIBLE_PROTOCOL;
+ CloseInternal(INCOMPATIBLE_PROTOCOL);
+ break;
default:
// TODO(sergeyu): There may be different reasons for error
// here. Parse the response stanza to find failure reason.
- error = PEER_IS_OFFLINE;
+ CloseInternal(PEER_IS_OFFLINE);
}
}
}
-
- CleanupPendingRequests(request);
-
- if (error != OK) {
- CloseInternal(error);
- }
}
void JingleSession::CleanupPendingRequests(IqRequest* request) {
@@ -528,7 +520,7 @@ void JingleSession::ProcessAuthenticationStep() {
if (authenticator_->state() == Authenticator::ACCEPTED) {
SetState(AUTHENTICATED);
} else if (authenticator_->state() == Authenticator::REJECTED) {
- CloseInternal(AuthRejectionReasonToError(
+ CloseInternal(AuthRejectionReasonToErrorCode(
authenticator_->rejection_reason()));
}
}
@@ -539,7 +531,7 @@ void JingleSession::SendTransportInfo() {
SendMessage(message);
}
-void JingleSession::CloseInternal(Error error) {
+void JingleSession::CloseInternal(ErrorCode error) {
DCHECK(CalledOnValidThread());
if (state_ == CONNECTING || state_ == CONNECTED || state_ == AUTHENTICATED) {

Powered by Google App Engine
This is Rietveld 408576698