summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-15 03:45:46 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-15 03:45:46 +0000
commit1f3dfe86e30f1c8e492b65ea8fe3b6978ac0552c (patch)
tree158a7e5d499db66c67a4a5241fc922914511b022 /remoting
parent1943d11ae0a8a306aa0da1920283c559a18b67ed (diff)
downloadchromium_src-1f3dfe86e30f1c8e492b65ea8fe3b6978ac0552c.zip
chromium_src-1f3dfe86e30f1c8e492b65ea8fe3b6978ac0552c.tar.gz
chromium_src-1f3dfe86e30f1c8e492b65ea8fe3b6978ac0552c.tar.bz2
Send correct termination reason when session is terminated by the host.
BUG=None TEST=None Review URL: http://codereview.chromium.org/8537020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110036 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/protocol/jingle_messages.cc1
-rw-r--r--remoting/protocol/jingle_messages.h1
-rw-r--r--remoting/protocol/jingle_session.cc36
-rw-r--r--remoting/protocol/jingle_session.h6
4 files changed, 33 insertions, 11 deletions
diff --git a/remoting/protocol/jingle_messages.cc b/remoting/protocol/jingle_messages.cc
index 1eaf69e..6c66641 100644
--- a/remoting/protocol/jingle_messages.cc
+++ b/remoting/protocol/jingle_messages.cc
@@ -65,6 +65,7 @@ static const NameMapElement<JingleMessage::ActionType> kActionTypes[] = {
static const NameMapElement<JingleMessage::Reason> kReasons[] = {
{ JingleMessage::SUCCESS, "success" },
{ JingleMessage::DECLINE, "decline" },
+ { JingleMessage::GENERAL_ERROR, "general-error" },
{ JingleMessage::INCOMPATIBLE_PARAMETERS, "incompatible-parameters" },
};
diff --git a/remoting/protocol/jingle_messages.h b/remoting/protocol/jingle_messages.h
index eb1ec5c..069d48f9 100644
--- a/remoting/protocol/jingle_messages.h
+++ b/remoting/protocol/jingle_messages.h
@@ -39,6 +39,7 @@ struct JingleMessage {
UNKNOWN_REASON,
SUCCESS,
DECLINE,
+ GENERAL_ERROR,
INCOMPATIBLE_PARAMETERS,
};
diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc
index b510ae8a..cbc404e 100644
--- a/remoting/protocol/jingle_session.cc
+++ b/remoting/protocol/jingle_session.cc
@@ -82,7 +82,7 @@ void JingleSession::Init(cricket::Session* cricket_session) {
this, &JingleSession::OnSessionError);
}
-void JingleSession::CloseInternal(int result, bool failed) {
+void JingleSession::CloseInternal(int result, Error error) {
DCHECK(CalledOnValidThread());
if (state_ != FAILED && state_ != CLOSED && !closing_) {
@@ -95,17 +95,34 @@ void JingleSession::CloseInternal(int result, bool failed) {
// Tear down the cricket session, including the cricket transport channels.
if (cricket_session_) {
- cricket_session_->Terminate();
+ std::string reason;
+ switch (error) {
+ case OK:
+ reason = cricket::STR_TERMINATE_SUCCESS;
+ break;
+ case SESSION_REJECTED:
+ reason = cricket::STR_TERMINATE_DECLINE;
+ break;
+ case INCOMPATIBLE_PROTOCOL:
+ reason = cricket::STR_TERMINATE_INCOMPATIBLE_PARAMETERS;
+ break;
+ default:
+ reason = cricket::STR_TERMINATE_ERROR;
+ }
+ cricket_session_->TerminateWithReason(reason);
cricket_session_->SignalState.disconnect(this);
}
+ error_ = error;
+
// Inform the StateChangeCallback, so calling code knows not to
// touch any channels. Needs to be done in the end because the
// session may be deleted in response to this event.
- if (failed)
+ if (error != OK) {
SetState(FAILED);
- else
+ } else {
SetState(CLOSED);
+ }
}
}
@@ -236,7 +253,7 @@ const std::string& JingleSession::shared_secret() {
void JingleSession::Close() {
DCHECK(CalledOnValidThread());
- CloseInternal(net::ERR_CONNECTION_CLOSED, false);
+ CloseInternal(net::ERR_CONNECTION_CLOSED, OK);
}
void JingleSession::OnSessionState(
@@ -284,7 +301,8 @@ void JingleSession::OnSessionError(
DCHECK_EQ(cricket_session_, session);
if (error != cricket::Session::ERROR_NONE) {
- CloseInternal(net::ERR_CONNECTION_ABORTED, true);
+ // TODO(sergeyu): Report different errors depending on |error|.
+ CloseInternal(net::ERR_CONNECTION_ABORTED, CHANNEL_CONNECTION_ERROR);
}
}
@@ -357,7 +375,7 @@ void JingleSession::OnAccept() {
if (cricket_session_->initiator()) {
if (!InitializeConfigFromDescription(
cricket_session_->remote_description())) {
- CloseInternal(net::ERR_CONNECTION_FAILED, true);
+ CloseInternal(net::ERR_CONNECTION_FAILED, INCOMPATIBLE_PROTOCOL);
return;
}
}
@@ -369,7 +387,7 @@ void JingleSession::OnAccept() {
void JingleSession::OnTerminate() {
DCHECK(CalledOnValidThread());
- CloseInternal(net::ERR_CONNECTION_ABORTED, false);
+ CloseInternal(net::ERR_CONNECTION_ABORTED, OK);
}
void JingleSession::AcceptConnection() {
@@ -434,7 +452,7 @@ void JingleSession::OnChannelConnected(
if (!socket) {
LOG(ERROR) << "Failed to connect control or events channel. "
<< "Terminating connection";
- CloseInternal(net::ERR_CONNECTION_CLOSED, true);
+ CloseInternal(net::ERR_CONNECTION_CLOSED, CHANNEL_CONNECTION_ERROR);
return;
}
diff --git a/remoting/protocol/jingle_session.h b/remoting/protocol/jingle_session.h
index 4bff001..787cc62 100644
--- a/remoting/protocol/jingle_session.h
+++ b/remoting/protocol/jingle_session.h
@@ -81,8 +81,10 @@ class JingleSession : public protocol::Session,
const std::string& local_certificate() const;
void Init(cricket::Session* cricket_session);
- // Close all the channels and terminate the session.
- void CloseInternal(int result, bool failed);
+ // Close all the channels and terminate the session. |result|
+ // defines error code that should returned to currently opened
+ // channels. |error| specified new value for error().
+ void CloseInternal(int result, Error error);
bool HasSession(cricket::Session* cricket_session);
cricket::Session* ReleaseSession();