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

Unified Diff: remoting/protocol/content_description.cc

Issue 10834446: Improve handling of NONE transport in channel configuration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/protocol/content_description_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/content_description.cc
diff --git a/remoting/protocol/content_description.cc b/remoting/protocol/content_description.cc
index eb2a892989468ea2790afb34ef4d8e64b359b414..61c3ff864af8ce360327daa24da2db1bd333c3ef 100644
--- a/remoting/protocol/content_description.cc
+++ b/remoting/protocol/content_description.cc
@@ -63,12 +63,14 @@ XmlElement* FormatChannelConfig(const ChannelConfig& config,
result->AddAttr(QName(kDefaultNs, kTransportAttr),
ValueToName(kTransports, config.transport));
- result->AddAttr(QName(kDefaultNs, kVersionAttr),
- base::IntToString(config.version));
+ if (config.transport != ChannelConfig::TRANSPORT_NONE) {
+ result->AddAttr(QName(kDefaultNs, kVersionAttr),
+ base::IntToString(config.version));
- if (config.codec != ChannelConfig::CODEC_UNDEFINED) {
- result->AddAttr(QName(kDefaultNs, kCodecAttr),
- ValueToName(kCodecs, config.codec));
+ if (config.codec != ChannelConfig::CODEC_UNDEFINED) {
+ result->AddAttr(QName(kDefaultNs, kCodecAttr),
+ ValueToName(kCodecs, config.codec));
+ }
}
return result;
@@ -79,18 +81,28 @@ bool ParseChannelConfig(const XmlElement* element, bool codec_required,
ChannelConfig* config) {
if (!NameToValue(
kTransports, element->Attr(QName(kDefaultNs, kTransportAttr)),
- &config->transport) ||
- !base::StringToInt(element->Attr(QName(kDefaultNs, kVersionAttr)),
- &config->version)) {
+ &config->transport)) {
return false;
}
- if (codec_required) {
- if (!NameToValue(kCodecs, element->Attr(QName(kDefaultNs, kCodecAttr)),
- &config->codec)) {
+ // Version is not required when transport="none".
+ if (config->transport != ChannelConfig::TRANSPORT_NONE) {
+ if (!base::StringToInt(element->Attr(QName(kDefaultNs, kVersionAttr)),
+ &config->version)) {
return false;
}
+
+ // Codec is not required when transport="none".
+ if (codec_required) {
+ if (!NameToValue(kCodecs, element->Attr(QName(kDefaultNs, kCodecAttr)),
+ &config->codec)) {
+ return false;
+ }
+ } else {
+ config->codec = ChannelConfig::CODEC_UNDEFINED;
+ }
} else {
+ config->version = 0;
config->codec = ChannelConfig::CODEC_UNDEFINED;
}
@@ -191,9 +203,7 @@ bool ContentDescription::ParseChannelConfigs(
if (optional && configs->empty()) {
// If there's no mention of the tag, implicitly assume
// TRANSPORT_NONE for the channel.
- configs->push_back(ChannelConfig(ChannelConfig::TRANSPORT_NONE,
- kDefaultStreamVersion,
- ChannelConfig::CODEC_VERBATIM));
+ configs->push_back(ChannelConfig());
}
return true;
}
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/protocol/content_description_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698