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

Unified Diff: remoting/protocol/pepper_session.cc

Issue 8046018: Parse termination reason and propagate the error to the Session interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 3 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/pepper_session.cc
diff --git a/remoting/protocol/pepper_session.cc b/remoting/protocol/pepper_session.cc
index 03167a901c68fdd201ca88099aa25b5724451777..e34c1e4cab1b8ff75934dc4a6c66acf101812b9c 100644
--- a/remoting/protocol/pepper_session.cc
+++ b/remoting/protocol/pepper_session.cc
@@ -34,7 +34,7 @@ const int kTransportInfoSendDelayMs = 2;
PepperSession::PepperSession(PepperSessionManager* session_manager)
: session_manager_(session_manager),
state_(INITIALIZING),
- error_(ERROR_NO_ERROR) {
+ error_(OK) {
}
PepperSession::~PepperSession() {
@@ -44,14 +44,14 @@ PepperSession::~PepperSession() {
session_manager_->SessionDestroyed(this);
}
-PepperSession::Error PepperSession::error() {
+void PepperSession::SetStateChangeCallback(StateChangeCallback* callback) {
DCHECK(CalledOnValidThread());
- return error_;
+ state_change_callback_.reset(callback);
}
-void PepperSession::SetStateChangeCallback(StateChangeCallback* callback) {
+Session::Error PepperSession::error() {
DCHECK(CalledOnValidThread());
- state_change_callback_.reset(callback);
+ return error_;
}
void PepperSession::StartConnection(
@@ -98,7 +98,7 @@ void PepperSession::OnSessionInitiateResponse(
// TODO(sergeyu): There may be different reasons for error
// here. Parse the response stanza to find failure reason.
- OnError(ERROR_PEER_IS_OFFLINE);
+ OnError(PEER_IS_OFFLINE);
}
}
@@ -222,10 +222,6 @@ void PepperSession::OnIncomingMessage(const JingleMessage& message,
ProcessTransportInfo(message);
break;
- case JingleMessage::SESSION_REJECT:
- OnReject(message, reply);
- break;
-
case JingleMessage::SESSION_TERMINATE:
OnTerminate(message, reply);
break;
@@ -243,7 +239,7 @@ void PepperSession::OnAccept(const JingleMessage& message,
}
if (!InitializeConfigFromDescription(message.description.get())) {
- OnError(ERROR_INCOMPATIBLE_PROTOCOL);
+ OnError(INCOMPATIBLE_PROTOCOL);
return;
}
@@ -267,24 +263,23 @@ void PepperSession::ProcessTransportInfo(const JingleMessage& message) {
}
}
-void PepperSession::OnReject(const JingleMessage& message,
- JingleMessageReply* reply) {
- if (state_ != CONNECTING) {
- *reply = JingleMessageReply(JingleMessageReply::UNEXPECTED_REQUEST);
- return;
- }
-
- // TODO(sergeyu): Parse exact rejection reason from reply and pass it
- // to OnError().
- OnError(ERROR_SESSION_REJECTED);
-}
-
void PepperSession::OnTerminate(const JingleMessage& message,
JingleMessageReply* reply) {
if (state_ == CONNECTING) {
- // If we are not connected yet, then interpret terminate message
- // as rejection.
- OnError(ERROR_SESSION_REJECTED);
+ switch (message.reason) {
+ case JingleMessage::DECLINED:
+ OnError(SESSION_REJECTED);
+ break;
+
+ case JingleMessage::INCOMPATIBLE_PARAMETERS:
+ OnError(INCOMPATIBLE_PROTOCOL);
+ break;
+
+ default:
+ LOG(WARNING) << "Received session-terminate message "
+ "with an unexpected reason.";
+ OnError(SESSION_REJECTED);
+ }
return;
}
@@ -355,7 +350,7 @@ void PepperSession::OnChannelConnected(
if (!socket) {
LOG(ERROR) << "Failed to connect control or events channel. "
<< "Terminating connection";
- OnError(ERROR_CHANNEL_CONNECTION_FAILURE);
+ OnError(CHANNEL_CONNECTION_ERROR);
return;
}

Powered by Google App Engine
This is Rietveld 408576698