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

Side by Side Diff: third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp

Issue 2519403002: binding: Lets Dictionary::getPropertyNames, etc. rethrow an exception. (Closed)
Patch Set: Fixed DictionaryTest. Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 certificates.size()); 339 certificates.size());
340 for (size_t i = 0; i < certificates.size(); ++i) { 340 for (size_t i = 0; i < certificates.size(); ++i) {
341 certificatesCopy[i] = certificates[i]->certificateShallowCopy(); 341 certificatesCopy[i] = certificates[i]->certificateShallowCopy();
342 } 342 }
343 webConfiguration.certificates = std::move(certificatesCopy); 343 webConfiguration.certificates = std::move(certificatesCopy);
344 } 344 }
345 345
346 return webConfiguration; 346 return webConfiguration;
347 } 347 }
348 348
349 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options) { 349 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options,
350 ExceptionState& exceptionState) {
350 if (options.isUndefinedOrNull()) 351 if (options.isUndefinedOrNull())
351 return 0; 352 return nullptr;
352 353
353 Vector<String> propertyNames; 354 Vector<String> propertyNames;
354 options.getPropertyNames(propertyNames); 355 if (!options.getPropertyNames(propertyNames, exceptionState))
356 return nullptr;
355 357
356 // Treat |options| as MediaConstraints if it is empty or has "optional" or 358 // Treat |options| as MediaConstraints if it is empty or has "optional" or
357 // "mandatory" properties for compatibility. 359 // "mandatory" properties for compatibility.
358 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and 360 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and
359 // client code is ready. 361 // client code is ready.
360 if (propertyNames.isEmpty() || propertyNames.contains("optional") || 362 if (propertyNames.isEmpty() || propertyNames.contains("optional") ||
361 propertyNames.contains("mandatory")) 363 propertyNames.contains("mandatory"))
362 return 0; 364 return nullptr;
363 365
364 int32_t offerToReceiveVideo = -1; 366 int32_t offerToReceiveVideo = -1;
365 int32_t offerToReceiveAudio = -1; 367 int32_t offerToReceiveAudio = -1;
366 bool voiceActivityDetection = true; 368 bool voiceActivityDetection = true;
367 bool iceRestart = false; 369 bool iceRestart = false;
368 370
369 if (DictionaryHelper::get(options, "offerToReceiveVideo", 371 if (DictionaryHelper::get(options, "offerToReceiveVideo",
370 offerToReceiveVideo) && 372 offerToReceiveVideo) &&
371 offerToReceiveVideo < 0) 373 offerToReceiveVideo < 0)
372 offerToReceiveVideo = 0; 374 offerToReceiveVideo = 0;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 context, UseCounter::RTCPeerConnectionCreateOfferOptionsOfferToReceive); 568 context, UseCounter::RTCPeerConnectionCreateOfferOptionsOfferToReceive);
567 } 569 }
568 m_peerHandler->createOffer(request, convertToWebRTCOfferOptions(options)); 570 m_peerHandler->createOffer(request, convertToWebRTCOfferOptions(options));
569 return promise; 571 return promise;
570 } 572 }
571 573
572 ScriptPromise RTCPeerConnection::createOffer( 574 ScriptPromise RTCPeerConnection::createOffer(
573 ScriptState* scriptState, 575 ScriptState* scriptState,
574 RTCSessionDescriptionCallback* successCallback, 576 RTCSessionDescriptionCallback* successCallback,
575 RTCPeerConnectionErrorCallback* errorCallback, 577 RTCPeerConnectionErrorCallback* errorCallback,
576 const Dictionary& rtcOfferOptions) { 578 const Dictionary& rtcOfferOptions,
579 ExceptionState& exceptionState) {
577 DCHECK(successCallback); 580 DCHECK(successCallback);
578 DCHECK(errorCallback); 581 DCHECK(errorCallback);
579 ExecutionContext* context = scriptState->getExecutionContext(); 582 ExecutionContext* context = scriptState->getExecutionContext();
580 UseCounter::count( 583 UseCounter::count(
581 context, UseCounter::RTCPeerConnectionCreateOfferLegacyFailureCallback); 584 context, UseCounter::RTCPeerConnectionCreateOfferLegacyFailureCallback);
582 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) 585 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback))
583 return ScriptPromise::castUndefined(scriptState); 586 return ScriptPromise::castUndefined(scriptState);
584 587
585 RTCOfferOptionsPlatform* offerOptions = parseOfferOptions(rtcOfferOptions); 588 RTCOfferOptionsPlatform* offerOptions =
589 parseOfferOptions(rtcOfferOptions, exceptionState);
590 if (exceptionState.hadException())
591 return ScriptPromise();
586 RTCSessionDescriptionRequest* request = 592 RTCSessionDescriptionRequest* request =
587 RTCSessionDescriptionRequestImpl::create(getExecutionContext(), this, 593 RTCSessionDescriptionRequestImpl::create(getExecutionContext(), this,
588 successCallback, errorCallback); 594 successCallback, errorCallback);
589 595
590 if (offerOptions) { 596 if (offerOptions) {
591 if (offerOptions->offerToReceiveAudio() != -1 || 597 if (offerOptions->offerToReceiveAudio() != -1 ||
592 offerOptions->offerToReceiveVideo() != -1) 598 offerOptions->offerToReceiveVideo() != -1)
593 UseCounter::count( 599 UseCounter::count(
594 context, UseCounter::RTCPeerConnectionCreateOfferLegacyOfferOptions); 600 context, UseCounter::RTCPeerConnectionCreateOfferLegacyOfferOptions);
595 else 601 else
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 DEFINE_TRACE(RTCPeerConnection) { 1487 DEFINE_TRACE(RTCPeerConnection) {
1482 visitor->trace(m_localStreams); 1488 visitor->trace(m_localStreams);
1483 visitor->trace(m_remoteStreams); 1489 visitor->trace(m_remoteStreams);
1484 visitor->trace(m_dispatchScheduledEventRunner); 1490 visitor->trace(m_dispatchScheduledEventRunner);
1485 visitor->trace(m_scheduledEvents); 1491 visitor->trace(m_scheduledEvents);
1486 EventTargetWithInlineData::trace(visitor); 1492 EventTargetWithInlineData::trace(visitor);
1487 ActiveDOMObject::trace(visitor); 1493 ActiveDOMObject::trace(visitor);
1488 } 1494 }
1489 1495
1490 } // namespace blink 1496 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698