Chromium Code Reviews| Index: remoting/protocol/jingle_messages.cc |
| diff --git a/remoting/protocol/jingle_messages.cc b/remoting/protocol/jingle_messages.cc |
| index 3113873b01280f3e310b165bb005364e44fbaa38..ddc71b8e27d889c0f96c713f80240f8b90e275b6 100644 |
| --- a/remoting/protocol/jingle_messages.cc |
| +++ b/remoting/protocol/jingle_messages.cc |
| @@ -49,7 +49,6 @@ const NameMapElement<JingleMessage::ActionType> kActionTypes[] = { |
| const NameMapElement<JingleMessage::Reason> kReasons[] = { |
| { JingleMessage::SUCCESS, "success" }, |
| { JingleMessage::DECLINE, "decline" }, |
| - { JingleMessage::SECURITY_ERROR, "security-error" }, |
| { JingleMessage::CANCEL, "cancel" }, |
| { JingleMessage::EXPIRED, "expired" }, |
| { JingleMessage::GENERAL_ERROR, "general-error" }, |
| @@ -343,6 +342,16 @@ bool JingleMessage::ParseXml(const buzz::XmlElement* stanza, |
| } |
| } |
| + const XmlElement* error_code_tag = |
| + jingle_tag->FirstNamed(QName(kChromotingXmlNamespace, "error-code")); |
| + if (error_code_tag && error_code_tag->FirstElement()) { |
| + if (!NameToValue(kErrorCodes, |
| + error_code_tag->FirstElement()->Name().LocalPart(), |
| + &error_code)) { |
| + error_code = UNKNOWN_ERROR; |
|
Sergey Ulanov
2016/06/02 09:26:03
log a warning that the error code wasn't recognize
Hzj_jie
2016/06/02 22:00:18
Done.
|
| + } |
| + } |
| + |
| if (action == SESSION_TERMINATE) |
| return true; |
| @@ -360,7 +369,7 @@ bool JingleMessage::ParseXml(const buzz::XmlElement* stanza, |
| } |
| const XmlElement* webrtc_transport_tag = content_tag->FirstNamed( |
| - QName("google:remoting:webrtc", "transport")); |
| + QName(kWebrtcTransportNamespace, "transport")); |
| if (webrtc_transport_tag) { |
| transport_info.reset(new buzz::XmlElement(*webrtc_transport_tag)); |
| } |
| @@ -424,12 +433,23 @@ std::unique_ptr<buzz::XmlElement> JingleMessage::ToXml() const { |
| if (reason != UNKNOWN_REASON) { |
| XmlElement* reason_tag = new XmlElement(QName(kJingleNamespace, "reason")); |
| jingle_tag->AddElement(reason_tag); |
| - const char* reason_string = |
| - ValueToName(kReasons, reason); |
| + const char* reason_string = ValueToName(kReasons, reason); |
| if (!reason_string) |
| LOG(FATAL) << "Invalid reason: " << reason; |
| reason_tag->AddElement(new XmlElement( |
| QName(kJingleNamespace, reason_string))); |
| + |
| + if (error_code != UNKNOWN_ERROR) { |
| + XmlElement* error_code_tag = |
| + new XmlElement(QName(kChromotingXmlNamespace, "error-code")); |
| + jingle_tag->AddElement(error_code_tag); |
| + const char* error_code_string = ValueToName(kErrorCodes, error_code); |
| + if (!error_code_string) { |
|
Sergey Ulanov
2016/06/02 09:26:04
replace with DCHECK(error_code_string)
Hzj_jie
2016/06/02 22:00:18
Done.
|
| + LOG(FATAL) << "Invalid error code: " << static_cast<int>(error_code); |
| + } |
| + error_code_tag->AddElement(new XmlElement( |
|
Sergey Ulanov
2016/06/02 09:26:03
I don't think we want to add the error as element.
Hzj_jie
2016/06/02 22:00:18
I used to implement as a text, but I found it's no
Sergey Ulanov
2016/06/03 08:43:22
I don't see how that can be a problem. When we gen
Hzj_jie
2016/06/03 21:46:33
Done.
|
| + QName(kChromotingXmlNamespace, error_code_string))); |
| + } |
| } |
| if (action != SESSION_TERMINATE) { |