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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 WTF::bind(&RTCPeerConnectionErrorCallback::handleEvent, 125 WTF::bind(&RTCPeerConnectionErrorCallback::handleEvent,
126 wrapPersistent(errorCallback), wrapPersistent(exception))); 126 wrapPersistent(errorCallback), wrapPersistent(exception)));
127 } 127 }
128 128
129 bool callErrorCallbackIfSignalingStateClosed( 129 bool callErrorCallbackIfSignalingStateClosed(
130 RTCPeerConnection::SignalingState state, 130 RTCPeerConnection::SignalingState state,
131 RTCPeerConnectionErrorCallback* errorCallback) { 131 RTCPeerConnectionErrorCallback* errorCallback) {
132 if (state == RTCPeerConnection::SignalingStateClosed) { 132 if (state == RTCPeerConnection::SignalingStateClosed) {
133 if (errorCallback) 133 if (errorCallback)
134 asyncCallErrorCallback( 134 asyncCallErrorCallback(
135 errorCallback, DOMException::create(InvalidStateError, 135 errorCallback,
136 kSignalingStateClosedMessage)); 136 DOMException::create(InvalidStateError,
137 kSignalingStateClosedMessage));
137 138
138 return true; 139 return true;
139 } 140 }
140 141
141 return false; 142 return false;
142 } 143 }
143 144
144 bool isIceCandidateMissingSdp( 145 bool isIceCandidateMissingSdp(
145 const RTCIceCandidateInitOrRTCIceCandidate& candidate) { 146 const RTCIceCandidateInitOrRTCIceCandidate& candidate) {
146 if (candidate.isRTCIceCandidateInit()) { 147 if (candidate.isRTCIceCandidateInit()) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 for (const String& urlString : urlStrings) { 301 for (const String& urlString : urlStrings) {
301 KURL url(KURL(), urlString); 302 KURL url(KURL(), urlString);
302 if (!url.isValid()) { 303 if (!url.isValid()) {
303 exceptionState.throwDOMException( 304 exceptionState.throwDOMException(
304 SyntaxError, "'" + urlString + "' is not a valid URL."); 305 SyntaxError, "'" + urlString + "' is not a valid URL.");
305 return WebRTCConfiguration(); 306 return WebRTCConfiguration();
306 } 307 }
307 if (!(url.protocolIs("turn") || url.protocolIs("turns") || 308 if (!(url.protocolIs("turn") || url.protocolIs("turns") ||
308 url.protocolIs("stun"))) { 309 url.protocolIs("stun"))) {
309 exceptionState.throwDOMException( 310 exceptionState.throwDOMException(
310 SyntaxError, "'" + url.protocol() + 311 SyntaxError,
311 "' is not one of the supported URL schemes " 312 "'" + url.protocol() +
312 "'stun', 'turn' or 'turns'."); 313 "' is not one of the supported URL schemes "
314 "'stun', 'turn' or 'turns'.");
313 return WebRTCConfiguration(); 315 return WebRTCConfiguration();
314 } 316 }
315 if ((url.protocolIs("turn") || url.protocolIs("turns")) && 317 if ((url.protocolIs("turn") || url.protocolIs("turns")) &&
316 (username.isNull() || credential.isNull())) { 318 (username.isNull() || credential.isNull())) {
317 exceptionState.throwDOMException(InvalidAccessError, 319 exceptionState.throwDOMException(InvalidAccessError,
318 "Both username and credential are " 320 "Both username and credential are "
319 "required when the URL scheme is " 321 "required when the URL scheme is "
320 "\"turn\" or \"turns\"."); 322 "\"turn\" or \"turns\".");
321 } 323 }
322 iceServers.push_back(WebRTCIceServer{url, username, credential}); 324 iceServers.push_back(WebRTCIceServer{url, username, credential});
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 const RTCSessionDescriptionInit& sessionDescriptionInit) { 681 const RTCSessionDescriptionInit& sessionDescriptionInit) {
680 if (m_signalingState == SignalingStateClosed) 682 if (m_signalingState == SignalingStateClosed)
681 return ScriptPromise::rejectWithDOMException( 683 return ScriptPromise::rejectWithDOMException(
682 scriptState, 684 scriptState,
683 DOMException::create(InvalidStateError, kSignalingStateClosedMessage)); 685 DOMException::create(InvalidStateError, kSignalingStateClosedMessage));
684 686
685 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 687 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
686 ScriptPromise promise = resolver->promise(); 688 ScriptPromise promise = resolver->promise();
687 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver); 689 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver);
688 m_peerHandler->setLocalDescription( 690 m_peerHandler->setLocalDescription(
689 request, WebRTCSessionDescription(sessionDescriptionInit.type(), 691 request,
690 sessionDescriptionInit.sdp())); 692 WebRTCSessionDescription(sessionDescriptionInit.type(),
693 sessionDescriptionInit.sdp()));
691 return promise; 694 return promise;
692 } 695 }
693 696
694 ScriptPromise RTCPeerConnection::setLocalDescription( 697 ScriptPromise RTCPeerConnection::setLocalDescription(
695 ScriptState* scriptState, 698 ScriptState* scriptState,
696 const RTCSessionDescriptionInit& sessionDescriptionInit, 699 const RTCSessionDescriptionInit& sessionDescriptionInit,
697 VoidCallback* successCallback, 700 VoidCallback* successCallback,
698 RTCPeerConnectionErrorCallback* errorCallback) { 701 RTCPeerConnectionErrorCallback* errorCallback) {
699 ExecutionContext* context = scriptState->getExecutionContext(); 702 ExecutionContext* context = scriptState->getExecutionContext();
700 if (successCallback && errorCallback) { 703 if (successCallback && errorCallback) {
(...skipping 12 matching lines...) Expand all
713 UseCounter:: 716 UseCounter::
714 RTCPeerConnectionSetLocalDescriptionLegacyNoFailureCallback); 717 RTCPeerConnectionSetLocalDescriptionLegacyNoFailureCallback);
715 } 718 }
716 719
717 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) 720 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback))
718 return ScriptPromise::castUndefined(scriptState); 721 return ScriptPromise::castUndefined(scriptState);
719 722
720 RTCVoidRequest* request = RTCVoidRequestImpl::create( 723 RTCVoidRequest* request = RTCVoidRequestImpl::create(
721 getExecutionContext(), this, successCallback, errorCallback); 724 getExecutionContext(), this, successCallback, errorCallback);
722 m_peerHandler->setLocalDescription( 725 m_peerHandler->setLocalDescription(
723 request, WebRTCSessionDescription(sessionDescriptionInit.type(), 726 request,
724 sessionDescriptionInit.sdp())); 727 WebRTCSessionDescription(sessionDescriptionInit.type(),
728 sessionDescriptionInit.sdp()));
725 return ScriptPromise::castUndefined(scriptState); 729 return ScriptPromise::castUndefined(scriptState);
726 } 730 }
727 731
728 RTCSessionDescription* RTCPeerConnection::localDescription() { 732 RTCSessionDescription* RTCPeerConnection::localDescription() {
729 WebRTCSessionDescription webSessionDescription = 733 WebRTCSessionDescription webSessionDescription =
730 m_peerHandler->localDescription(); 734 m_peerHandler->localDescription();
731 if (webSessionDescription.isNull()) 735 if (webSessionDescription.isNull())
732 return nullptr; 736 return nullptr;
733 737
734 return RTCSessionDescription::create(webSessionDescription); 738 return RTCSessionDescription::create(webSessionDescription);
735 } 739 }
736 740
737 ScriptPromise RTCPeerConnection::setRemoteDescription( 741 ScriptPromise RTCPeerConnection::setRemoteDescription(
738 ScriptState* scriptState, 742 ScriptState* scriptState,
739 const RTCSessionDescriptionInit& sessionDescriptionInit) { 743 const RTCSessionDescriptionInit& sessionDescriptionInit) {
740 if (m_signalingState == SignalingStateClosed) 744 if (m_signalingState == SignalingStateClosed)
741 return ScriptPromise::rejectWithDOMException( 745 return ScriptPromise::rejectWithDOMException(
742 scriptState, 746 scriptState,
743 DOMException::create(InvalidStateError, kSignalingStateClosedMessage)); 747 DOMException::create(InvalidStateError, kSignalingStateClosedMessage));
744 748
745 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 749 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
746 ScriptPromise promise = resolver->promise(); 750 ScriptPromise promise = resolver->promise();
747 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver); 751 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver);
748 m_peerHandler->setRemoteDescription( 752 m_peerHandler->setRemoteDescription(
749 request, WebRTCSessionDescription(sessionDescriptionInit.type(), 753 request,
750 sessionDescriptionInit.sdp())); 754 WebRTCSessionDescription(sessionDescriptionInit.type(),
755 sessionDescriptionInit.sdp()));
751 return promise; 756 return promise;
752 } 757 }
753 758
754 ScriptPromise RTCPeerConnection::setRemoteDescription( 759 ScriptPromise RTCPeerConnection::setRemoteDescription(
755 ScriptState* scriptState, 760 ScriptState* scriptState,
756 const RTCSessionDescriptionInit& sessionDescriptionInit, 761 const RTCSessionDescriptionInit& sessionDescriptionInit,
757 VoidCallback* successCallback, 762 VoidCallback* successCallback,
758 RTCPeerConnectionErrorCallback* errorCallback) { 763 RTCPeerConnectionErrorCallback* errorCallback) {
759 ExecutionContext* context = scriptState->getExecutionContext(); 764 ExecutionContext* context = scriptState->getExecutionContext();
760 if (successCallback && errorCallback) { 765 if (successCallback && errorCallback) {
(...skipping 12 matching lines...) Expand all
773 UseCounter:: 778 UseCounter::
774 RTCPeerConnectionSetRemoteDescriptionLegacyNoFailureCallback); 779 RTCPeerConnectionSetRemoteDescriptionLegacyNoFailureCallback);
775 } 780 }
776 781
777 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) 782 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback))
778 return ScriptPromise::castUndefined(scriptState); 783 return ScriptPromise::castUndefined(scriptState);
779 784
780 RTCVoidRequest* request = RTCVoidRequestImpl::create( 785 RTCVoidRequest* request = RTCVoidRequestImpl::create(
781 getExecutionContext(), this, successCallback, errorCallback); 786 getExecutionContext(), this, successCallback, errorCallback);
782 m_peerHandler->setRemoteDescription( 787 m_peerHandler->setRemoteDescription(
783 request, WebRTCSessionDescription(sessionDescriptionInit.type(), 788 request,
784 sessionDescriptionInit.sdp())); 789 WebRTCSessionDescription(sessionDescriptionInit.type(),
790 sessionDescriptionInit.sdp()));
785 return ScriptPromise::castUndefined(scriptState); 791 return ScriptPromise::castUndefined(scriptState);
786 } 792 }
787 793
788 RTCSessionDescription* RTCPeerConnection::remoteDescription() { 794 RTCSessionDescription* RTCPeerConnection::remoteDescription() {
789 WebRTCSessionDescription webSessionDescription = 795 WebRTCSessionDescription webSessionDescription =
790 m_peerHandler->remoteDescription(); 796 m_peerHandler->remoteDescription();
791 if (webSessionDescription.isNull()) 797 if (webSessionDescription.isNull())
792 return nullptr; 798 return nullptr;
793 799
794 return RTCSessionDescription::create(webSessionDescription); 800 return RTCSessionDescription::create(webSessionDescription);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 WebCryptoNamedCurveP256) { 909 WebCryptoNamedCurveP256) {
904 keyParams.set(WebRTCKeyParams::createECDSA(WebRTCECCurveNistP256)); 910 keyParams.set(WebRTCKeyParams::createECDSA(WebRTCECCurveNistP256));
905 } else { 911 } else {
906 return ScriptPromise::rejectWithDOMException( 912 return ScriptPromise::rejectWithDOMException(
907 scriptState, 913 scriptState,
908 DOMException::create(NotSupportedError, unsupportedParamsString)); 914 DOMException::create(NotSupportedError, unsupportedParamsString));
909 } 915 }
910 break; 916 break;
911 default: 917 default:
912 return ScriptPromise::rejectWithDOMException( 918 return ScriptPromise::rejectWithDOMException(
913 scriptState, DOMException::create(NotSupportedError, 919 scriptState,
914 "The 1st argument provided is an " 920 DOMException::create(NotSupportedError,
915 "AlgorithmIdentifier, but the " 921 "The 1st argument provided is an "
916 "algorithm is not supported.")); 922 "AlgorithmIdentifier, but the "
923 "algorithm is not supported."));
917 break; 924 break;
918 } 925 }
919 DCHECK(!keyParams.isNull()); 926 DCHECK(!keyParams.isNull());
920 927
921 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator = 928 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator =
922 WTF::wrapUnique(Platform::current()->createRTCCertificateGenerator()); 929 WTF::wrapUnique(Platform::current()->createRTCCertificateGenerator());
923 930
924 // |keyParams| was successfully constructed, but does the certificate 931 // |keyParams| was successfully constructed, but does the certificate
925 // generator support these parameters? 932 // generator support these parameters?
926 if (!certificateGenerator->isSupportedKeyParams(keyParams.get())) { 933 if (!certificateGenerator->isSupportedKeyParams(keyParams.get())) {
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 DEFINE_TRACE(RTCPeerConnection) { 1501 DEFINE_TRACE(RTCPeerConnection) {
1495 visitor->trace(m_localStreams); 1502 visitor->trace(m_localStreams);
1496 visitor->trace(m_remoteStreams); 1503 visitor->trace(m_remoteStreams);
1497 visitor->trace(m_dispatchScheduledEventRunner); 1504 visitor->trace(m_dispatchScheduledEventRunner);
1498 visitor->trace(m_scheduledEvents); 1505 visitor->trace(m_scheduledEvents);
1499 EventTargetWithInlineData::trace(visitor); 1506 EventTargetWithInlineData::trace(visitor);
1500 SuspendableObject::trace(visitor); 1507 SuspendableObject::trace(visitor);
1501 } 1508 }
1502 1509
1503 } // namespace blink 1510 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698