Chromium Code Reviews| Index: talk/app/webrtc/peerconnectionfactory.cc |
| diff --git a/talk/app/webrtc/peerconnectionfactory.cc b/talk/app/webrtc/peerconnectionfactory.cc |
| index 26765d21097ff81a791b4ac54b64fa207eb0d48c..19e2d109a0675ed41db44f657c0e33bbb399916a 100644 |
| --- a/talk/app/webrtc/peerconnectionfactory.cc |
| +++ b/talk/app/webrtc/peerconnectionfactory.cc |
| @@ -228,20 +228,39 @@ PeerConnectionFactory::CreatePeerConnection( |
| PortAllocatorFactoryInterface* allocator_factory, |
| rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| PeerConnectionObserver* observer) { |
|
Henrik Grunell WebRTC
2015/08/12 14:46:29
Keep the dchecks here as well. And in the new func
hbos
2015/08/14 14:09:38
Done.
|
| - DCHECK(signaling_thread_->IsCurrent()); |
| - DCHECK(allocator_factory || default_allocator_factory_); |
| + PortAllocatorFactoryInterface* chosen_allocator_factory = |
| + CreatePeerConnectionCommon(allocator_factory); |
| if (!dtls_identity_store.get()) { |
| - // Because |pc|->Initialize takes ownership of the store we need a new |
| - // wrapper object that can be deleted without deleting the underlying |
| - // |dtls_identity_store_|, protecting it from being deleted multiple times. |
| + // Because |pc|->Initialize takes ownership of the store in Pass()ing we |
| + // need a new wrapper object that can be passed and eventually deleted |
| + // without passing and deleting our |dtls_identity_store_|. |
| dtls_identity_store.reset( |
| new DtlsIdentityStoreWrapper(dtls_identity_store_)); |
| } |
| + rtc::scoped_refptr<PeerConnection> pc( |
| + new rtc::RefCountedObject<PeerConnection>(this)); |
| + if (!pc->Initialize( |
| + configuration, |
| + constraints, |
| + chosen_allocator_factory, |
| + dtls_identity_store.Pass(), |
| + observer)) { |
| + return nullptr; |
| + } |
| + return PeerConnectionProxy::Create(signaling_thread(), pc); |
| +} |
| + |
| +rtc::scoped_refptr<PeerConnectionInterface> |
| +PeerConnectionFactory::CreatePeerConnection( |
| + const PeerConnectionInterface::RTCConfiguration& configuration, |
| + const MediaConstraintsInterface* constraints, |
| + PortAllocatorFactoryInterface* allocator_factory, |
| + const rtc::scoped_refptr<DtlsCertificate>& certificate, |
| + PeerConnectionObserver* observer) { |
| PortAllocatorFactoryInterface* chosen_allocator_factory = |
| - allocator_factory ? allocator_factory : default_allocator_factory_.get(); |
| - chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); |
| + CreatePeerConnectionCommon(allocator_factory); |
| rtc::scoped_refptr<PeerConnection> pc( |
| new rtc::RefCountedObject<PeerConnection>(this)); |
| @@ -249,13 +268,26 @@ PeerConnectionFactory::CreatePeerConnection( |
| configuration, |
| constraints, |
| chosen_allocator_factory, |
| - dtls_identity_store.Pass(), |
| + certificate, |
| observer)) { |
| - return NULL; |
| + return nullptr; |
| } |
| return PeerConnectionProxy::Create(signaling_thread(), pc); |
| } |
| +PortAllocatorFactoryInterface* |
| +PeerConnectionFactory::CreatePeerConnectionCommon( |
|
Henrik Grunell WebRTC
2015/08/12 14:46:29
This function should be called something so one kn
hbos
2015/08/14 14:09:39
Done.
|
| + PortAllocatorFactoryInterface* allocator_factory) { |
| + DCHECK(signaling_thread_->IsCurrent()); |
| + DCHECK(allocator_factory || default_allocator_factory_); |
| + |
| + PortAllocatorFactoryInterface* chosen_allocator_factory = |
| + allocator_factory ? allocator_factory : default_allocator_factory_.get(); |
| + chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); |
| + |
| + return chosen_allocator_factory; |
| +} |
| + |
| rtc::scoped_refptr<MediaStreamInterface> |
| PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
| DCHECK(signaling_thread_->IsCurrent()); |