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

Side by Side Diff: remoting/protocol/content_description.cc

Issue 10831022: Skip unknown channel configurations when parsing session config. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/content_description.h" 5 #include "remoting/protocol/content_description.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "remoting/base/constants.h" 9 #include "remoting/base/constants.h"
10 #include "remoting/protocol/authenticator.h" 10 #include "remoting/protocol/authenticator.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 const XmlElement* const element, 228 const XmlElement* const element,
229 const char tag_name[], 229 const char tag_name[],
230 bool codec_required, 230 bool codec_required,
231 bool optional, 231 bool optional,
232 std::vector<ChannelConfig>* const configs) { 232 std::vector<ChannelConfig>* const configs) {
233 233
234 QName tag(kChromotingXmlNamespace, tag_name); 234 QName tag(kChromotingXmlNamespace, tag_name);
235 const XmlElement* child = element->FirstNamed(tag); 235 const XmlElement* child = element->FirstNamed(tag);
236 while (child) { 236 while (child) {
237 ChannelConfig channel_config; 237 ChannelConfig channel_config;
238 if (!ParseChannelConfig(child, codec_required, &channel_config)) 238 if (ParseChannelConfig(child, codec_required, &channel_config)) {
239 return false; 239 configs->push_back(channel_config);
240 configs->push_back(channel_config); 240 }
241 child = child->NextNamed(tag); 241 child = child->NextNamed(tag);
242 } 242 }
243 if (optional && configs->empty()) { 243 if (optional && configs->empty()) {
244 // If there's no mention of the tag, implicitly assume 244 // If there's no mention of the tag, implicitly assume
245 // TRANSPORT_NONE for the channel. 245 // TRANSPORT_NONE for the channel.
246 configs->push_back(ChannelConfig(ChannelConfig::TRANSPORT_NONE, 246 configs->push_back(ChannelConfig(ChannelConfig::TRANSPORT_NONE,
247 kDefaultStreamVersion, 247 kDefaultStreamVersion,
248 ChannelConfig::CODEC_VERBATIM)); 248 ChannelConfig::CODEC_VERBATIM));
249 } 249 }
250 return true; 250 return true;
251 } 251 }
252 252
253 // static 253 // static
254 ContentDescription* ContentDescription::ParseXml( 254 scoped_ptr<ContentDescription> ContentDescription::ParseXml(
255 const XmlElement* element) { 255 const XmlElement* element) {
256 if (element->Name() == QName(kChromotingXmlNamespace, kDescriptionTag)) { 256 if (element->Name() != QName(kChromotingXmlNamespace, kDescriptionTag)) {
257 scoped_ptr<CandidateSessionConfig> config( 257 LOG(ERROR) << "Invalid description: " << element->Str();
258 CandidateSessionConfig::CreateEmpty()); 258 return scoped_ptr<ContentDescription>();
259 const XmlElement* child = NULL; 259 }
260 scoped_ptr<CandidateSessionConfig> config(
261 CandidateSessionConfig::CreateEmpty());
262 if (!ParseChannelConfigs(element, kControlTag, false, false,
263 config->mutable_control_configs()) ||
264 !ParseChannelConfigs(element, kEventTag, false, false,
265 config->mutable_event_configs()) ||
266 !ParseChannelConfigs(element, kVideoTag, true, false,
267 config->mutable_video_configs()) ||
268 !ParseChannelConfigs(element, kAudioTag, true, true,
269 config->mutable_audio_configs())) {
270 return scoped_ptr<ContentDescription>();
271 }
260 272
261 if (!ParseChannelConfigs(element, kControlTag, false, false, 273 scoped_ptr<XmlElement> authenticator_message;
262 config->mutable_control_configs())) { 274 const XmlElement* child = Authenticator::FindAuthenticatorMessage(element);
263 return NULL; 275 if (child)
264 } 276 authenticator_message.reset(new XmlElement(*child));
265 if (!ParseChannelConfigs(element, kEventTag, false, false,
266 config->mutable_event_configs())) {
267 return NULL;
268 }
269 if (!ParseChannelConfigs(element, kVideoTag, true, false,
270 config->mutable_video_configs())) {
271 return NULL;
272 }
273 if (!ParseChannelConfigs(element, kAudioTag, true, true,
274 config->mutable_audio_configs())) {
275 return NULL;
276 }
277 277
278 scoped_ptr<XmlElement> authenticator_message; 278 return scoped_ptr<ContentDescription>(
279 child = Authenticator::FindAuthenticatorMessage(element); 279 new ContentDescription(config.Pass(), authenticator_message.Pass()));
280 if (child)
281 authenticator_message.reset(new XmlElement(*child));
282
283 return new ContentDescription(config.Pass(), authenticator_message.Pass());
284 }
285 LOG(ERROR) << "Invalid description: " << element->Str();
286 return NULL;
287 } 280 }
288 281
289 } // namespace protocol 282 } // namespace protocol
290 } // namespace remoting 283 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/content_description.h ('k') | remoting/protocol/content_description_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698