| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 if (candidate.isRTCIceCandidateInit()) { | 133 if (candidate.isRTCIceCandidateInit()) { |
| 134 const RTCIceCandidateInit& iceCandidateInit = candidate.getAsRTCIceCandi
dateInit(); | 134 const RTCIceCandidateInit& iceCandidateInit = candidate.getAsRTCIceCandi
dateInit(); |
| 135 return WebRTCICECandidate(iceCandidateInit.candidate(), iceCandidateInit
.sdpMid(), iceCandidateInit.sdpMLineIndex()); | 135 return WebRTCICECandidate(iceCandidateInit.candidate(), iceCandidateInit
.sdpMid(), iceCandidateInit.sdpMLineIndex()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 ASSERT(candidate.isRTCIceCandidate()); | 138 ASSERT(candidate.isRTCIceCandidate()); |
| 139 return candidate.getAsRTCIceCandidate()->webCandidate(); | 139 return candidate.getAsRTCIceCandidate()->webCandidate(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Helper class for RTCPeerConnection::generateCertificate. | 142 // Helper class for RTCPeerConnection::generateCertificate. |
| 143 class WebRTCCertificateObserver : public WebCallbacks<WebRTCCertificate*, void>
{ | 143 class WebRTCCertificateObserver : public WebRTCCertificateCallback { |
| 144 public: | 144 public: |
| 145 // The created observer is responsible for deleting itself after onSuccess/o
nError. To avoid memory | 145 // Takes ownership of |resolver|. |
| 146 // leak the observer should therefore be used in a WebRTCCertificateGenerato
r::generateCertificate call | |
| 147 // which is ensured to invoke one of these. Takes ownership of |resolver|. | |
| 148 static WebRTCCertificateObserver* create(ScriptPromiseResolver* resolver) | 146 static WebRTCCertificateObserver* create(ScriptPromiseResolver* resolver) |
| 149 { | 147 { |
| 150 return new WebRTCCertificateObserver(resolver); | 148 return new WebRTCCertificateObserver(resolver); |
| 151 } | 149 } |
| 152 | 150 |
| 151 ~WebRTCCertificateObserver() override {} |
| 152 |
| 153 DEFINE_INLINE_TRACE() { visitor->trace(m_resolver); } | 153 DEFINE_INLINE_TRACE() { visitor->trace(m_resolver); } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 WebRTCCertificateObserver(ScriptPromiseResolver* resolver) | 156 WebRTCCertificateObserver(ScriptPromiseResolver* resolver) |
| 157 : m_resolver(resolver) {} | 157 : m_resolver(resolver) {} |
| 158 | 158 |
| 159 ~WebRTCCertificateObserver() override {} | 159 void onSuccess(WebPassOwnPtr<WebRTCCertificate> certificate) override |
| 160 | |
| 161 void onSuccess(WebRTCCertificate* certificate) override | |
| 162 { | 160 { |
| 163 m_resolver->resolve(new RTCCertificate(certificate)); | 161 m_resolver->resolve(new RTCCertificate(certificate)); |
| 164 delete this; | |
| 165 } | 162 } |
| 166 | 163 |
| 167 void onError() override | 164 void onError() override |
| 168 { | 165 { |
| 169 m_resolver->reject(); | 166 m_resolver->reject(); |
| 170 delete this; | |
| 171 } | 167 } |
| 172 | 168 |
| 173 Persistent<ScriptPromiseResolver> m_resolver; | 169 Persistent<ScriptPromiseResolver> m_resolver; |
| 174 }; | 170 }; |
| 175 | 171 |
| 176 } // namespace | 172 } // namespace |
| 177 | 173 |
| 178 RTCPeerConnection::EventWrapper::EventWrapper( | 174 RTCPeerConnection::EventWrapper::EventWrapper( |
| 179 PassRefPtrWillBeRawPtr<Event> event, | 175 PassRefPtrWillBeRawPtr<Event> event, |
| 180 PassOwnPtr<BoolFunction> function) | 176 PassOwnPtr<BoolFunction> function) |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 Platform::current()->createRTCCertificateGenerator()); | 649 Platform::current()->createRTCCertificateGenerator()); |
| 654 | 650 |
| 655 // |keyParams| was successfully constructed, but does the certificate genera
tor support these parameters? | 651 // |keyParams| was successfully constructed, but does the certificate genera
tor support these parameters? |
| 656 if (!certificateGenerator->isSupportedKeyParams(keyParams.get())) { | 652 if (!certificateGenerator->isSupportedKeyParams(keyParams.get())) { |
| 657 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError, unsupportedParamsString)); | 653 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError, unsupportedParamsString)); |
| 658 } | 654 } |
| 659 | 655 |
| 660 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 656 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 661 ScriptPromise promise = resolver->promise(); | 657 ScriptPromise promise = resolver->promise(); |
| 662 | 658 |
| 663 WebRTCCertificateObserver* certificateObserver = WebRTCCertificateObserver::
create(resolver); | 659 WebPassOwnPtr<WebRTCCertificateObserver> certificateObserver = adoptWebPtr(W
ebRTCCertificateObserver::create(resolver)); |
| 664 | 660 |
| 665 // Generate certificate. The |certificateObserver| will resolve the promise
asynchronously upon completion. | 661 // Generate certificate. The |certificateObserver| will resolve the promise
asynchronously upon completion. |
| 666 // The observer will manage its own destruction as well as the resolver's de
struction. | 662 // The observer will manage its own destruction as well as the resolver's de
struction. |
| 667 certificateGenerator->generateCertificate( | 663 certificateGenerator->generateCertificate( |
| 668 keyParams.get(), | 664 keyParams.get(), |
| 669 toDocument(scriptState->getExecutionContext())->url(), | 665 toDocument(scriptState->getExecutionContext())->url(), |
| 670 toDocument(scriptState->getExecutionContext())->firstPartyForCookies(), | 666 toDocument(scriptState->getExecutionContext())->firstPartyForCookies(), |
| 671 certificateObserver); | 667 certificateObserver); |
| 672 | 668 |
| 673 return promise; | 669 return promise; |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 { | 1117 { |
| 1122 visitor->trace(m_localStreams); | 1118 visitor->trace(m_localStreams); |
| 1123 visitor->trace(m_remoteStreams); | 1119 visitor->trace(m_remoteStreams); |
| 1124 visitor->trace(m_dispatchScheduledEventRunner); | 1120 visitor->trace(m_dispatchScheduledEventRunner); |
| 1125 visitor->trace(m_scheduledEvents); | 1121 visitor->trace(m_scheduledEvents); |
| 1126 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); | 1122 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); |
| 1127 ActiveDOMObject::trace(visitor); | 1123 ActiveDOMObject::trace(visitor); |
| 1128 } | 1124 } |
| 1129 | 1125 |
| 1130 } // namespace blink | 1126 } // namespace blink |
| OLD | NEW |