Prepare to move packet_socket_factory to api/.

I gave up on removing proxy_info, user_agent and tcp_options. I don't
think it's feasible to remove them without removing all the proxy code.
The assumption that you can set the proxy and user agent long after
you have created the factory is entrenched in unit tests and the code
itself. So is the ability to set tcp opts depending on protocol or
endpoint properties.

It may be easier to untangle proxy stuff from the factory later,
when it becomes a more first-class citizen and isn't passed via
the allocator.

Requires https://chromium-review.googlesource.com/c/chromium/src/+/1778870
to land first.

Bug: webrtc:7447
Change-Id: Ib496e2bb689ea415e9f8ec1dfedff13a83fa4a8a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150799
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29091}
This commit is contained in:
Patrik Höglund
2019-09-05 14:35:04 +02:00
committed by Commit Bot
parent 50b0baf510
commit 662e31ffec
14 changed files with 140 additions and 173 deletions

View File

@ -229,7 +229,7 @@ PeerConnectionFactory::CreatePeerConnection(
std::unique_ptr<cricket::PortAllocator> allocator,
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
PeerConnectionObserver* observer) {
// Convert the legacy API into the new depnedency structure.
// Convert the legacy API into the new dependency structure.
PeerConnectionDependencies dependencies(observer);
dependencies.allocator = std::move(allocator);
dependencies.cert_generator = std::move(cert_generator);
@ -242,6 +242,9 @@ PeerConnectionFactory::CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
PeerConnectionDependencies dependencies) {
RTC_DCHECK(signaling_thread_->IsCurrent());
RTC_DCHECK(!(dependencies.allocator && dependencies.packet_socket_factory))
<< "You can't set both allocator and packet_socket_factory; "
"the former is going away (see bugs.webrtc.org/7447";
// Set internal defaults if optional dependencies are not set.
if (!dependencies.cert_generator) {
@ -250,10 +253,17 @@ PeerConnectionFactory::CreatePeerConnection(
network_thread_);
}
if (!dependencies.allocator) {
rtc::PacketSocketFactory* packet_socket_factory;
if (dependencies.packet_socket_factory)
packet_socket_factory = dependencies.packet_socket_factory.get();
else
packet_socket_factory = default_socket_factory_.get();
network_thread_->Invoke<void>(RTC_FROM_HERE, [this, &configuration,
&dependencies]() {
&dependencies,
&packet_socket_factory]() {
dependencies.allocator = absl::make_unique<cricket::BasicPortAllocator>(
default_network_manager_.get(), default_socket_factory_.get(),
default_network_manager_.get(), packet_socket_factory,
configuration.turn_customizer);
});
}