Create port allocator on signaling thread and init on network

Port allocator can be created on one thread and then initialized and
used on another. So we can avoid sync invoke to network thread to create
port allocator.

Bug: webrtc:11799
Change-Id: I5020093a41acbf7e372f2e4970e016ce14a7f406
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180122
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31805}
diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc
index b274d57..d3b7fcd 100644
--- a/pc/peer_connection_factory.cc
+++ b/pc/peer_connection_factory.cc
@@ -262,13 +262,9 @@
     else
       packet_socket_factory = default_socket_factory_.get();
 
-    network_thread_->Invoke<void>(RTC_FROM_HERE, [this, &configuration,
-                                                  &dependencies,
-                                                  &packet_socket_factory]() {
-      dependencies.allocator = std::make_unique<cricket::BasicPortAllocator>(
-          default_network_manager_.get(), packet_socket_factory,
-          configuration.turn_customizer);
-    });
+    dependencies.allocator = std::make_unique<cricket::BasicPortAllocator>(
+        default_network_manager_.get(), packet_socket_factory,
+        configuration.turn_customizer);
   }
 
   if (!dependencies.async_resolver_factory) {
@@ -281,10 +277,7 @@
         std::make_unique<DefaultIceTransportFactory>();
   }
 
-  network_thread_->Invoke<void>(
-      RTC_FROM_HERE,
-      rtc::Bind(&cricket::PortAllocator::SetNetworkIgnoreMask,
-                dependencies.allocator.get(), options_.network_ignore_mask));
+  dependencies.allocator->SetNetworkIgnoreMask(options_.network_ignore_mask);
 
   std::unique_ptr<RtcEventLog> event_log =
       worker_thread_->Invoke<std::unique_ptr<RtcEventLog>>(