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

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

Issue 1865913005: Nuke WebPassOwnPtr<T> and replace it with std::unique_ptr<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "public/platform/WebRTCDataChannelHandler.h" 81 #include "public/platform/WebRTCDataChannelHandler.h"
82 #include "public/platform/WebRTCDataChannelInit.h" 82 #include "public/platform/WebRTCDataChannelInit.h"
83 #include "public/platform/WebRTCICECandidate.h" 83 #include "public/platform/WebRTCICECandidate.h"
84 #include "public/platform/WebRTCKeyParams.h" 84 #include "public/platform/WebRTCKeyParams.h"
85 #include "public/platform/WebRTCOfferOptions.h" 85 #include "public/platform/WebRTCOfferOptions.h"
86 #include "public/platform/WebRTCSessionDescription.h" 86 #include "public/platform/WebRTCSessionDescription.h"
87 #include "public/platform/WebRTCSessionDescriptionRequest.h" 87 #include "public/platform/WebRTCSessionDescriptionRequest.h"
88 #include "public/platform/WebRTCStatsRequest.h" 88 #include "public/platform/WebRTCStatsRequest.h"
89 #include "public/platform/WebRTCVoidRequest.h" 89 #include "public/platform/WebRTCVoidRequest.h"
90 90
91 #include <memory>
92
91 namespace blink { 93 namespace blink {
92 94
93 namespace { 95 namespace {
94 96
95 const char kSignalingStateClosedMessage[] = "The RTCPeerConnection's signalingSt ate is 'closed'."; 97 const char kSignalingStateClosedMessage[] = "The RTCPeerConnection's signalingSt ate is 'closed'.";
96 98
97 bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingState stat e, ExceptionState& exceptionState) 99 bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingState stat e, ExceptionState& exceptionState)
98 { 100 {
99 if (state == RTCPeerConnection::SignalingStateClosed) { 101 if (state == RTCPeerConnection::SignalingStateClosed) {
100 exceptionState.throwDOMException(InvalidStateError, kSignalingStateClose dMessage); 102 exceptionState.throwDOMException(InvalidStateError, kSignalingStateClose dMessage);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 class WebRTCCertificateObserver : public WebRTCCertificateCallback { 164 class WebRTCCertificateObserver : public WebRTCCertificateCallback {
163 public: 165 public:
164 // Takes ownership of |resolver|. 166 // Takes ownership of |resolver|.
165 static WebRTCCertificateObserver* create(ScriptPromiseResolver* resolver) 167 static WebRTCCertificateObserver* create(ScriptPromiseResolver* resolver)
166 { 168 {
167 return new WebRTCCertificateObserver(resolver); 169 return new WebRTCCertificateObserver(resolver);
168 } 170 }
169 171
170 ~WebRTCCertificateObserver() override {} 172 ~WebRTCCertificateObserver() override {}
171 173
172 DEFINE_INLINE_TRACE() { visitor->trace(m_resolver); }
173
174 private: 174 private:
175 WebRTCCertificateObserver(ScriptPromiseResolver* resolver) 175 WebRTCCertificateObserver(ScriptPromiseResolver* resolver)
176 : m_resolver(resolver) {} 176 : m_resolver(resolver) {}
177 177
178 void onSuccess(WebPassOwnPtr<WebRTCCertificate> certificate) override 178 void onSuccess(std::unique_ptr<WebRTCCertificate> certificate) override
179 { 179 {
180 m_resolver->resolve(new RTCCertificate(certificate)); 180 m_resolver->resolve(new RTCCertificate(std::move(certificate)));
181 } 181 }
182 182
183 void onError() override 183 void onError() override
184 { 184 {
185 m_resolver->reject(); 185 m_resolver->reject();
186 } 186 }
187 187
188 Persistent<ScriptPromiseResolver> m_resolver; 188 Persistent<ScriptPromiseResolver> m_resolver;
189 }; 189 };
190 190
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 Platform::current()->createRTCCertificateGenerator()); 698 Platform::current()->createRTCCertificateGenerator());
699 699
700 // |keyParams| was successfully constructed, but does the certificate genera tor support these parameters? 700 // |keyParams| was successfully constructed, but does the certificate genera tor support these parameters?
701 if (!certificateGenerator->isSupportedKeyParams(keyParams.get())) { 701 if (!certificateGenerator->isSupportedKeyParams(keyParams.get())) {
702 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError, unsupportedParamsString)); 702 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError, unsupportedParamsString));
703 } 703 }
704 704
705 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 705 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
706 ScriptPromise promise = resolver->promise(); 706 ScriptPromise promise = resolver->promise();
707 707
708 WebPassOwnPtr<WebRTCCertificateObserver> certificateObserver = adoptWebPtr(W ebRTCCertificateObserver::create(resolver)); 708 std::unique_ptr<WebRTCCertificateObserver> certificateObserver(WebRTCCertifi cateObserver::create(resolver));
709 709
710 // Generate certificate. The |certificateObserver| will resolve the promise asynchronously upon completion. 710 // Generate certificate. The |certificateObserver| will resolve the promise asynchronously upon completion.
711 // The observer will manage its own destruction as well as the resolver's de struction. 711 // The observer will manage its own destruction as well as the resolver's de struction.
712 certificateGenerator->generateCertificate( 712 certificateGenerator->generateCertificate(
713 keyParams.get(), 713 keyParams.get(),
714 toDocument(scriptState->getExecutionContext())->url(), 714 toDocument(scriptState->getExecutionContext())->url(),
715 toDocument(scriptState->getExecutionContext())->firstPartyForCookies(), 715 toDocument(scriptState->getExecutionContext())->firstPartyForCookies(),
716 certificateObserver); 716 std::move(certificateObserver));
717 717
718 return promise; 718 return promise;
719 } 719 }
720 720
721 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate) 721 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate)
722 { 722 {
723 if (m_signalingState == SignalingStateClosed) 723 if (m_signalingState == SignalingStateClosed)
724 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage)); 724 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage));
725 725
726 if (isIceCandidateMissingSdp(candidate)) 726 if (isIceCandidateMissingSdp(candidate))
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 { 1166 {
1167 visitor->trace(m_localStreams); 1167 visitor->trace(m_localStreams);
1168 visitor->trace(m_remoteStreams); 1168 visitor->trace(m_remoteStreams);
1169 visitor->trace(m_dispatchScheduledEventRunner); 1169 visitor->trace(m_dispatchScheduledEventRunner);
1170 visitor->trace(m_scheduledEvents); 1170 visitor->trace(m_scheduledEvents);
1171 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); 1171 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor);
1172 ActiveDOMObject::trace(visitor); 1172 ActiveDOMObject::trace(visitor);
1173 } 1173 }
1174 1174
1175 } // namespace blink 1175 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698