| OLD | NEW |
| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 return rtcConfiguration; | 371 return rtcConfiguration; |
| 372 } | 372 } |
| 373 | 373 |
| 374 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options) { | 374 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options) { |
| 375 if (options.isUndefinedOrNull()) | 375 if (options.isUndefinedOrNull()) |
| 376 return 0; | 376 return 0; |
| 377 | 377 |
| 378 Vector<String> propertyNames; | 378 Vector<String> propertyNames; |
| 379 options.getPropertyNames(propertyNames); | 379 options.getPropertyNames(propertyNames); |
| 380 | 380 |
| 381 // Treat |options| as MediaConstraints if it is empty or has "optional" or "ma
ndatory" properties for compatibility. | 381 // Treat |options| as MediaConstraints if it is empty or has "optional" or |
| 382 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and cli
ent code is ready. | 382 // "mandatory" properties for compatibility. |
| 383 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and |
| 384 // client code is ready. |
| 383 if (propertyNames.isEmpty() || propertyNames.contains("optional") || | 385 if (propertyNames.isEmpty() || propertyNames.contains("optional") || |
| 384 propertyNames.contains("mandatory")) | 386 propertyNames.contains("mandatory")) |
| 385 return 0; | 387 return 0; |
| 386 | 388 |
| 387 int32_t offerToReceiveVideo = -1; | 389 int32_t offerToReceiveVideo = -1; |
| 388 int32_t offerToReceiveAudio = -1; | 390 int32_t offerToReceiveAudio = -1; |
| 389 bool voiceActivityDetection = true; | 391 bool voiceActivityDetection = true; |
| 390 bool iceRestart = false; | 392 bool iceRestart = false; |
| 391 | 393 |
| 392 if (DictionaryHelper::get(options, "offerToReceiveVideo", | 394 if (DictionaryHelper::get(options, "offerToReceiveVideo", |
| 393 offerToReceiveVideo) && | 395 offerToReceiveVideo) && |
| 394 offerToReceiveVideo < 0) | 396 offerToReceiveVideo < 0) |
| 395 offerToReceiveVideo = 0; | 397 offerToReceiveVideo = 0; |
| 396 if (DictionaryHelper::get(options, "offerToReceiveAudio", | 398 if (DictionaryHelper::get(options, "offerToReceiveAudio", |
| 397 offerToReceiveAudio) && | 399 offerToReceiveAudio) && |
| 398 offerToReceiveAudio < 0) | 400 offerToReceiveAudio < 0) |
| 399 offerToReceiveAudio = 0; | 401 offerToReceiveAudio = 0; |
| 400 DictionaryHelper::get(options, "voiceActivityDetection", | 402 DictionaryHelper::get(options, "voiceActivityDetection", |
| 401 voiceActivityDetection); | 403 voiceActivityDetection); |
| 402 DictionaryHelper::get(options, "iceRestart", iceRestart); | 404 DictionaryHelper::get(options, "iceRestart", iceRestart); |
| 403 | 405 |
| 404 RTCOfferOptionsPlatform* rtcOfferOptions = | 406 RTCOfferOptionsPlatform* rtcOfferOptions = |
| 405 RTCOfferOptionsPlatform::create(offerToReceiveVideo, offerToReceiveAudio, | 407 RTCOfferOptionsPlatform::create(offerToReceiveVideo, offerToReceiveAudio, |
| 406 voiceActivityDetection, iceRestart); | 408 voiceActivityDetection, iceRestart); |
| 407 return rtcOfferOptions; | 409 return rtcOfferOptions; |
| 408 } | 410 } |
| 409 | 411 |
| 410 // Helper class for |RTCPeerConnection::getStats(ScriptState*, MediaStreamTrack*
)| | 412 // Helper class for |
| 413 // |RTCPeerConnection::getStats(ScriptState*, MediaStreamTrack*)| |
| 411 class WebRTCStatsReportCallbackResolver : public WebRTCStatsReportCallback { | 414 class WebRTCStatsReportCallbackResolver : public WebRTCStatsReportCallback { |
| 412 public: | 415 public: |
| 413 // Takes ownership of |resolver|. | 416 // Takes ownership of |resolver|. |
| 414 static std::unique_ptr<WebRTCStatsReportCallback> create( | 417 static std::unique_ptr<WebRTCStatsReportCallback> create( |
| 415 ScriptPromiseResolver* resolver) { | 418 ScriptPromiseResolver* resolver) { |
| 416 return std::unique_ptr<WebRTCStatsReportCallback>( | 419 return std::unique_ptr<WebRTCStatsReportCallback>( |
| 417 new WebRTCStatsReportCallbackResolver(resolver)); | 420 new WebRTCStatsReportCallbackResolver(resolver)); |
| 418 } | 421 } |
| 419 | 422 |
| 420 ~WebRTCStatsReportCallbackResolver() override {} | 423 ~WebRTCStatsReportCallbackResolver() override {} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 const Dictionary& rtcConfiguration, | 455 const Dictionary& rtcConfiguration, |
| 453 const Dictionary& mediaConstraints, | 456 const Dictionary& mediaConstraints, |
| 454 ExceptionState& exceptionState) { | 457 ExceptionState& exceptionState) { |
| 455 if (mediaConstraints.isObject()) | 458 if (mediaConstraints.isObject()) |
| 456 UseCounter::count(context, | 459 UseCounter::count(context, |
| 457 UseCounter::RTCPeerConnectionConstructorConstraints); | 460 UseCounter::RTCPeerConnectionConstructorConstraints); |
| 458 else | 461 else |
| 459 UseCounter::count(context, | 462 UseCounter::count(context, |
| 460 UseCounter::RTCPeerConnectionConstructorCompliant); | 463 UseCounter::RTCPeerConnectionConstructorCompliant); |
| 461 | 464 |
| 462 // Record the RtcpMuxPolicy for histogram "WebRTC.PeerConnection.SelectedRtcpM
uxPolicy". | 465 // Record the RtcpMuxPolicy for histogram |
| 466 // "WebRTC.PeerConnection.SelectedRtcpMuxPolicy". |
| 463 RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; | 467 RtcpMuxPolicy selectedRtcpMuxPolicy = RtcpMuxPolicyDefault; |
| 464 RTCConfiguration* configuration = parseConfiguration( | 468 RTCConfiguration* configuration = parseConfiguration( |
| 465 rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); | 469 rtcConfiguration, exceptionState, &selectedRtcpMuxPolicy); |
| 466 if (exceptionState.hadException()) | 470 if (exceptionState.hadException()) |
| 467 return 0; | 471 return 0; |
| 468 | 472 |
| 469 // Make sure no certificates have expired. | 473 // Make sure no certificates have expired. |
| 470 if (configuration && configuration->numberOfCertificates() > 0) { | 474 if (configuration && configuration->numberOfCertificates() > 0) { |
| 471 DOMTimeStamp now = convertSecondsToDOMTimeStamp(currentTime()); | 475 DOMTimeStamp now = convertSecondsToDOMTimeStamp(currentTime()); |
| 472 for (size_t i = 0; i < configuration->numberOfCertificates(); ++i) { | 476 for (size_t i = 0; i < configuration->numberOfCertificates(); ++i) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 m_iceConnectionState(ICEConnectionStateNew), | 514 m_iceConnectionState(ICEConnectionStateNew), |
| 511 m_dispatchScheduledEventRunner( | 515 m_dispatchScheduledEventRunner( |
| 512 AsyncMethodRunner<RTCPeerConnection>::create( | 516 AsyncMethodRunner<RTCPeerConnection>::create( |
| 513 this, | 517 this, |
| 514 &RTCPeerConnection::dispatchScheduledEvent)), | 518 &RTCPeerConnection::dispatchScheduledEvent)), |
| 515 m_stopped(false), | 519 m_stopped(false), |
| 516 m_closed(false) { | 520 m_closed(false) { |
| 517 ThreadState::current()->registerPreFinalizer(this); | 521 ThreadState::current()->registerPreFinalizer(this); |
| 518 Document* document = toDocument(getExecutionContext()); | 522 Document* document = toDocument(getExecutionContext()); |
| 519 | 523 |
| 520 // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the as
sert in the destructor. | 524 // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the |
| 525 // assert in the destructor. |
| 521 | 526 |
| 522 if (!document->frame()) { | 527 if (!document->frame()) { |
| 523 m_closed = true; | 528 m_closed = true; |
| 524 m_stopped = true; | 529 m_stopped = true; |
| 525 exceptionState.throwDOMException( | 530 exceptionState.throwDOMException( |
| 526 NotSupportedError, | 531 NotSupportedError, |
| 527 "PeerConnections may not be created in detached documents."); | 532 "PeerConnections may not be created in detached documents."); |
| 528 return; | 533 return; |
| 529 } | 534 } |
| 530 | 535 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 548 m_closed = true; | 553 m_closed = true; |
| 549 m_stopped = true; | 554 m_stopped = true; |
| 550 exceptionState.throwDOMException( | 555 exceptionState.throwDOMException( |
| 551 NotSupportedError, "Failed to initialize native PeerConnection."); | 556 NotSupportedError, "Failed to initialize native PeerConnection."); |
| 552 return; | 557 return; |
| 553 } | 558 } |
| 554 } | 559 } |
| 555 | 560 |
| 556 RTCPeerConnection::~RTCPeerConnection() { | 561 RTCPeerConnection::~RTCPeerConnection() { |
| 557 // This checks that close() or stop() is called before the destructor. | 562 // This checks that close() or stop() is called before the destructor. |
| 558 // We are assuming that a wrapper is always created when RTCPeerConnection is
created. | 563 // We are assuming that a wrapper is always created when RTCPeerConnection is |
| 564 // created. |
| 559 DCHECK(m_closed || m_stopped); | 565 DCHECK(m_closed || m_stopped); |
| 560 } | 566 } |
| 561 | 567 |
| 562 void RTCPeerConnection::dispose() { | 568 void RTCPeerConnection::dispose() { |
| 563 // Promptly clears a raw reference from content/ to an on-heap object | 569 // Promptly clears a raw reference from content/ to an on-heap object |
| 564 // so that content/ doesn't access it in a lazy sweeping phase. | 570 // so that content/ doesn't access it in a lazy sweeping phase. |
| 565 m_peerHandler.reset(); | 571 m_peerHandler.reset(); |
| 566 } | 572 } |
| 567 | 573 |
| 568 ScriptPromise RTCPeerConnection::createOffer(ScriptState* scriptState, | 574 ScriptPromise RTCPeerConnection::createOffer(ScriptState* scriptState, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 context, UseCounter::RTCPeerConnectionCreateOfferLegacyOfferOptions); | 616 context, UseCounter::RTCPeerConnectionCreateOfferLegacyOfferOptions); |
| 611 else | 617 else |
| 612 UseCounter::count( | 618 UseCounter::count( |
| 613 context, UseCounter::RTCPeerConnectionCreateOfferLegacyCompliant); | 619 context, UseCounter::RTCPeerConnectionCreateOfferLegacyCompliant); |
| 614 | 620 |
| 615 m_peerHandler->createOffer(request, WebRTCOfferOptions(offerOptions)); | 621 m_peerHandler->createOffer(request, WebRTCOfferOptions(offerOptions)); |
| 616 } else { | 622 } else { |
| 617 MediaErrorState mediaErrorState; | 623 MediaErrorState mediaErrorState; |
| 618 WebMediaConstraints constraints = | 624 WebMediaConstraints constraints = |
| 619 MediaConstraintsImpl::create(context, rtcOfferOptions, mediaErrorState); | 625 MediaConstraintsImpl::create(context, rtcOfferOptions, mediaErrorState); |
| 620 // Report constraints parsing errors via the callback, but ignore unknown/un
supported constraints as they | 626 // Report constraints parsing errors via the callback, but ignore |
| 621 // would be silently discarded by WebIDL. | 627 // unknown/unsupported constraints as they would be silently discarded by |
| 628 // WebIDL. |
| 622 if (mediaErrorState.canGenerateException()) { | 629 if (mediaErrorState.canGenerateException()) { |
| 623 String errorMsg = mediaErrorState.getErrorMessage(); | 630 String errorMsg = mediaErrorState.getErrorMessage(); |
| 624 asyncCallErrorCallback(errorCallback, | 631 asyncCallErrorCallback(errorCallback, |
| 625 DOMException::create(OperationError, errorMsg)); | 632 DOMException::create(OperationError, errorMsg)); |
| 626 return ScriptPromise::castUndefined(scriptState); | 633 return ScriptPromise::castUndefined(scriptState); |
| 627 } | 634 } |
| 628 | 635 |
| 629 if (!constraints.isEmpty()) | 636 if (!constraints.isEmpty()) |
| 630 UseCounter::count( | 637 UseCounter::count( |
| 631 context, UseCounter::RTCPeerConnectionCreateOfferLegacyConstraints); | 638 context, UseCounter::RTCPeerConnectionCreateOfferLegacyConstraints); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 else | 677 else |
| 671 UseCounter::count(context, | 678 UseCounter::count(context, |
| 672 UseCounter::RTCPeerConnectionCreateAnswerLegacyCompliant); | 679 UseCounter::RTCPeerConnectionCreateAnswerLegacyCompliant); |
| 673 | 680 |
| 674 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) | 681 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) |
| 675 return ScriptPromise::castUndefined(scriptState); | 682 return ScriptPromise::castUndefined(scriptState); |
| 676 | 683 |
| 677 MediaErrorState mediaErrorState; | 684 MediaErrorState mediaErrorState; |
| 678 WebMediaConstraints constraints = | 685 WebMediaConstraints constraints = |
| 679 MediaConstraintsImpl::create(context, mediaConstraints, mediaErrorState); | 686 MediaConstraintsImpl::create(context, mediaConstraints, mediaErrorState); |
| 680 // Report constraints parsing errors via the callback, but ignore unknown/unsu
pported constraints as they | 687 // Report constraints parsing errors via the callback, but ignore |
| 681 // would be silently discarded by WebIDL. | 688 // unknown/unsupported constraints as they would be silently discarded by |
| 689 // WebIDL. |
| 682 if (mediaErrorState.canGenerateException()) { | 690 if (mediaErrorState.canGenerateException()) { |
| 683 String errorMsg = mediaErrorState.getErrorMessage(); | 691 String errorMsg = mediaErrorState.getErrorMessage(); |
| 684 asyncCallErrorCallback(errorCallback, | 692 asyncCallErrorCallback(errorCallback, |
| 685 DOMException::create(OperationError, errorMsg)); | 693 DOMException::create(OperationError, errorMsg)); |
| 686 return ScriptPromise::castUndefined(scriptState); | 694 return ScriptPromise::castUndefined(scriptState); |
| 687 } | 695 } |
| 688 | 696 |
| 689 RTCSessionDescriptionRequest* request = | 697 RTCSessionDescriptionRequest* request = |
| 690 RTCSessionDescriptionRequestImpl::create(getExecutionContext(), this, | 698 RTCSessionDescriptionRequestImpl::create(getExecutionContext(), this, |
| 691 successCallback, errorCallback); | 699 successCallback, errorCallback); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 if (!valid) | 846 if (!valid) |
| 839 exceptionState.throwDOMException( | 847 exceptionState.throwDOMException( |
| 840 SyntaxError, | 848 SyntaxError, |
| 841 "Could not update the ICE Agent with the given configuration."); | 849 "Could not update the ICE Agent with the given configuration."); |
| 842 } | 850 } |
| 843 | 851 |
| 844 ScriptPromise RTCPeerConnection::generateCertificate( | 852 ScriptPromise RTCPeerConnection::generateCertificate( |
| 845 ScriptState* scriptState, | 853 ScriptState* scriptState, |
| 846 const AlgorithmIdentifier& keygenAlgorithm, | 854 const AlgorithmIdentifier& keygenAlgorithm, |
| 847 ExceptionState& exceptionState) { | 855 ExceptionState& exceptionState) { |
| 848 // Normalize |keygenAlgorithm| with WebCrypto, making sure it is a recognized
AlgorithmIdentifier. | 856 // Normalize |keygenAlgorithm| with WebCrypto, making sure it is a recognized |
| 857 // AlgorithmIdentifier. |
| 849 WebCryptoAlgorithm cryptoAlgorithm; | 858 WebCryptoAlgorithm cryptoAlgorithm; |
| 850 AlgorithmError error; | 859 AlgorithmError error; |
| 851 if (!normalizeAlgorithm(keygenAlgorithm, WebCryptoOperationGenerateKey, | 860 if (!normalizeAlgorithm(keygenAlgorithm, WebCryptoOperationGenerateKey, |
| 852 cryptoAlgorithm, &error)) { | 861 cryptoAlgorithm, &error)) { |
| 853 // Reject generateCertificate with the same error as was produced by WebCryp
to. | 862 // Reject generateCertificate with the same error as was produced by |
| 854 // |result| is garbage collected, no need to delete. | 863 // WebCrypto. |result| is garbage collected, no need to delete. |
| 855 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 864 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
| 856 ScriptPromise promise = result->promise(); | 865 ScriptPromise promise = result->promise(); |
| 857 result->completeWithError(error.errorType, error.errorDetails); | 866 result->completeWithError(error.errorType, error.errorDetails); |
| 858 return promise; | 867 return promise; |
| 859 } | 868 } |
| 860 | 869 |
| 861 // Check if |keygenAlgorithm| contains the optional DOMTimeStamp |expires| att
ribute. | 870 // Check if |keygenAlgorithm| contains the optional DOMTimeStamp |expires| |
| 871 // attribute. |
| 862 Nullable<DOMTimeStamp> expires; | 872 Nullable<DOMTimeStamp> expires; |
| 863 if (keygenAlgorithm.isDictionary()) { | 873 if (keygenAlgorithm.isDictionary()) { |
| 864 Dictionary keygenAlgorithmDict = keygenAlgorithm.getAsDictionary(); | 874 Dictionary keygenAlgorithmDict = keygenAlgorithm.getAsDictionary(); |
| 865 if (keygenAlgorithmDict.hasProperty("expires")) { | 875 if (keygenAlgorithmDict.hasProperty("expires")) { |
| 866 v8::Local<v8::Value> expiresValue; | 876 v8::Local<v8::Value> expiresValue; |
| 867 keygenAlgorithmDict.get("expires", expiresValue); | 877 keygenAlgorithmDict.get("expires", expiresValue); |
| 868 if (expiresValue->IsNumber()) { | 878 if (expiresValue->IsNumber()) { |
| 869 double expiresDouble = | 879 double expiresDouble = |
| 870 expiresValue->ToNumber(scriptState->isolate()->GetCurrentContext()) | 880 expiresValue->ToNumber(scriptState->isolate()->GetCurrentContext()) |
| 871 .ToLocalChecked() | 881 .ToLocalChecked() |
| 872 ->Value(); | 882 ->Value(); |
| 873 if (expiresDouble >= 0) { | 883 if (expiresDouble >= 0) { |
| 874 expires.set(static_cast<DOMTimeStamp>(expiresDouble)); | 884 expires.set(static_cast<DOMTimeStamp>(expiresDouble)); |
| 875 } | 885 } |
| 876 } | 886 } |
| 877 } | 887 } |
| 878 } | 888 } |
| 879 | 889 |
| 880 // Convert from WebCrypto representation to recognized WebRTCKeyParams. WebRTC
supports a small subset of what are valid AlgorithmIdentifiers. | 890 // Convert from WebCrypto representation to recognized WebRTCKeyParams. WebRTC |
| 891 // supports a small subset of what are valid AlgorithmIdentifiers. |
| 881 const char* unsupportedParamsString = | 892 const char* unsupportedParamsString = |
| 882 "The 1st argument provided is an AlgorithmIdentifier with a supported " | 893 "The 1st argument provided is an AlgorithmIdentifier with a supported " |
| 883 "algorithm name, but the parameters are not supported."; | 894 "algorithm name, but the parameters are not supported."; |
| 884 Nullable<WebRTCKeyParams> keyParams; | 895 Nullable<WebRTCKeyParams> keyParams; |
| 885 switch (cryptoAlgorithm.id()) { | 896 switch (cryptoAlgorithm.id()) { |
| 886 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: | 897 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: |
| 887 // name: "RSASSA-PKCS1-v1_5" | 898 // name: "RSASSA-PKCS1-v1_5" |
| 888 unsigned publicExponent; | 899 unsigned publicExponent; |
| 889 // "publicExponent" must fit in an unsigned int. The only recognized "hash
" is "SHA-256". | 900 // "publicExponent" must fit in an unsigned int. The only recognized |
| 901 // "hash" is "SHA-256". |
| 890 if (cryptoAlgorithm.rsaHashedKeyGenParams() | 902 if (cryptoAlgorithm.rsaHashedKeyGenParams() |
| 891 ->convertPublicExponentToUnsigned(publicExponent) && | 903 ->convertPublicExponentToUnsigned(publicExponent) && |
| 892 cryptoAlgorithm.rsaHashedKeyGenParams()->hash().id() == | 904 cryptoAlgorithm.rsaHashedKeyGenParams()->hash().id() == |
| 893 WebCryptoAlgorithmIdSha256) { | 905 WebCryptoAlgorithmIdSha256) { |
| 894 unsigned modulusLength = | 906 unsigned modulusLength = |
| 895 cryptoAlgorithm.rsaHashedKeyGenParams()->modulusLengthBits(); | 907 cryptoAlgorithm.rsaHashedKeyGenParams()->modulusLengthBits(); |
| 896 keyParams.set( | 908 keyParams.set( |
| 897 WebRTCKeyParams::createRSA(modulusLength, publicExponent)); | 909 WebRTCKeyParams::createRSA(modulusLength, publicExponent)); |
| 898 } else { | 910 } else { |
| 899 return ScriptPromise::rejectWithDOMException( | 911 return ScriptPromise::rejectWithDOMException( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 919 "The 1st argument provided is an " | 931 "The 1st argument provided is an " |
| 920 "AlgorithmIdentifier, but the " | 932 "AlgorithmIdentifier, but the " |
| 921 "algorithm is not supported.")); | 933 "algorithm is not supported.")); |
| 922 break; | 934 break; |
| 923 } | 935 } |
| 924 DCHECK(!keyParams.isNull()); | 936 DCHECK(!keyParams.isNull()); |
| 925 | 937 |
| 926 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator = | 938 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator = |
| 927 wrapUnique(Platform::current()->createRTCCertificateGenerator()); | 939 wrapUnique(Platform::current()->createRTCCertificateGenerator()); |
| 928 | 940 |
| 929 // |keyParams| was successfully constructed, but does the certificate generato
r support these parameters? | 941 // |keyParams| was successfully constructed, but does the certificate |
| 942 // generator support these parameters? |
| 930 if (!certificateGenerator->isSupportedKeyParams(keyParams.get())) { | 943 if (!certificateGenerator->isSupportedKeyParams(keyParams.get())) { |
| 931 return ScriptPromise::rejectWithDOMException( | 944 return ScriptPromise::rejectWithDOMException( |
| 932 scriptState, | 945 scriptState, |
| 933 DOMException::create(NotSupportedError, unsupportedParamsString)); | 946 DOMException::create(NotSupportedError, unsupportedParamsString)); |
| 934 } | 947 } |
| 935 | 948 |
| 936 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 949 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 937 ScriptPromise promise = resolver->promise(); | 950 ScriptPromise promise = resolver->promise(); |
| 938 | 951 |
| 939 std::unique_ptr<WebRTCCertificateObserver> certificateObserver( | 952 std::unique_ptr<WebRTCCertificateObserver> certificateObserver( |
| 940 WebRTCCertificateObserver::create(resolver)); | 953 WebRTCCertificateObserver::create(resolver)); |
| 941 | 954 |
| 942 // Generate certificate. The |certificateObserver| will resolve the promise as
ynchronously upon completion. | 955 // Generate certificate. The |certificateObserver| will resolve the promise |
| 943 // The observer will manage its own destruction as well as the resolver's dest
ruction. | 956 // asynchronously upon completion. The observer will manage its own |
| 957 // destruction as well as the resolver's destruction. |
| 944 if (expires.isNull()) { | 958 if (expires.isNull()) { |
| 945 certificateGenerator->generateCertificate(keyParams.get(), | 959 certificateGenerator->generateCertificate(keyParams.get(), |
| 946 std::move(certificateObserver)); | 960 std::move(certificateObserver)); |
| 947 } else { | 961 } else { |
| 948 certificateGenerator->generateCertificateWithExpiration( | 962 certificateGenerator->generateCertificateWithExpiration( |
| 949 keyParams.get(), expires.get(), std::move(certificateObserver)); | 963 keyParams.get(), expires.get(), std::move(certificateObserver)); |
| 950 } | 964 } |
| 951 | 965 |
| 952 return promise; | 966 return promise; |
| 953 } | 967 } |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 DEFINE_TRACE(RTCPeerConnection) { | 1494 DEFINE_TRACE(RTCPeerConnection) { |
| 1481 visitor->trace(m_localStreams); | 1495 visitor->trace(m_localStreams); |
| 1482 visitor->trace(m_remoteStreams); | 1496 visitor->trace(m_remoteStreams); |
| 1483 visitor->trace(m_dispatchScheduledEventRunner); | 1497 visitor->trace(m_dispatchScheduledEventRunner); |
| 1484 visitor->trace(m_scheduledEvents); | 1498 visitor->trace(m_scheduledEvents); |
| 1485 EventTargetWithInlineData::trace(visitor); | 1499 EventTargetWithInlineData::trace(visitor); |
| 1486 ActiveDOMObject::trace(visitor); | 1500 ActiveDOMObject::trace(visitor); |
| 1487 } | 1501 } |
| 1488 | 1502 |
| 1489 } // namespace blink | 1503 } // namespace blink |
| OLD | NEW |