More minor improvements to BaseChannel/transport code.

Mostly from late comments on this CL:
https://codereview.webrtc.org/2614263002/

Changes SetTransport to DCHECK instead of returning false.
Renames it to SetTransports.
Fixes some possible transport resource leaks.

BUG=None

Review-Url: https://codereview.webrtc.org/2637503003
Cr-Commit-Position: refs/heads/master@{#16130}
diff --git a/webrtc/api/webrtcsession.cc b/webrtc/api/webrtcsession.cc
index a0c72c8..8487d2c 100644
--- a/webrtc/api/webrtcsession.cc
+++ b/webrtc/api/webrtcsession.cc
@@ -1092,18 +1092,16 @@
           transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
     }
 
-    if (!ch->SetTransport(rtp_transport, rtcp_transport)) {
-      LOG(LS_WARNING) << "Failed to enable BUNDLE for " << ch->content_name();
-      return false;
-    }
+    ch->SetTransports(rtp_transport, rtcp_transport);
     LOG(LS_INFO) << "Enabled BUNDLE for " << ch->content_name() << " on "
                  << transport_name << ".";
-    DestroyTransport(old_transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+    transport_controller_->DestroyTransportChannel(
+        old_transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
     // If the channel needs rtcp, it means that the channel used to have a
     // rtcp transport which needs to be deleted now.
     if (need_rtcp) {
-      DestroyTransport(old_transport_name,
-                       cricket::ICE_CANDIDATE_COMPONENT_RTCP);
+      transport_controller_->DestroyTransportChannel(
+          old_transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
     }
     return true;
   };
@@ -1805,6 +1803,12 @@
       transport_controller_->signaling_thread(), content->name,
       bundle_transport, require_rtcp_mux, SrtpRequired(), audio_options_));
   if (!voice_channel_) {
+    transport_controller_->DestroyTransportChannel(
+        transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+    if (rtcp_transport) {
+      transport_controller_->DestroyTransportChannel(
+          transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+    }
     return false;
   }
 
@@ -1842,6 +1846,12 @@
       bundle_transport, require_rtcp_mux, SrtpRequired(), video_options_));
 
   if (!video_channel_) {
+    transport_controller_->DestroyTransportChannel(
+        transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+    if (rtcp_transport) {
+      transport_controller_->DestroyTransportChannel(
+          transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+    }
     return false;
   }
 
@@ -1901,6 +1911,12 @@
         bundle_transport, require_rtcp_mux, SrtpRequired()));
 
     if (!rtp_data_channel_) {
+      transport_controller_->DestroyTransportChannel(
+          transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+      if (rtcp_transport) {
+        transport_controller_->DestroyTransportChannel(
+            transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+      }
       return false;
     }
 
@@ -2365,14 +2381,6 @@
   return channel->transport_name();
 }
 
-void WebRtcSession::DestroyTransport(const std::string& transport_name,
-                                     int component) {
-  network_thread_->Invoke<void>(
-      RTC_FROM_HERE,
-      rtc::Bind(&cricket::TransportController::DestroyTransportChannel_n,
-                transport_controller_.get(), transport_name, component));
-}
-
 void WebRtcSession::DestroyRtcpTransport_n(const std::string& transport_name) {
   RTC_DCHECK(network_thread()->IsCurrent());
   transport_controller_->DestroyTransportChannel_n(
@@ -2386,9 +2394,11 @@
   transport_name = video_channel_->rtp_transport()->transport_name();
   bool need_to_delete_rtcp = (video_channel_->rtcp_transport() != nullptr);
   channel_manager_->DestroyVideoChannel(video_channel_.release());
-  DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+  transport_controller_->DestroyTransportChannel(
+      transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
   if (need_to_delete_rtcp) {
-    DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
+    transport_controller_->DestroyTransportChannel(
+        transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
   }
 }
 
@@ -2399,9 +2409,11 @@
   transport_name = voice_channel_->rtp_transport()->transport_name();
   bool need_to_delete_rtcp = (voice_channel_->rtcp_transport() != nullptr);
   channel_manager_->DestroyVoiceChannel(voice_channel_.release());
-  DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+  transport_controller_->DestroyTransportChannel(
+      transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
   if (need_to_delete_rtcp) {
-    DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
+    transport_controller_->DestroyTransportChannel(
+        transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
   }
 }
 
@@ -2412,9 +2424,11 @@
   transport_name = rtp_data_channel_->rtp_transport()->transport_name();
   bool need_to_delete_rtcp = (rtp_data_channel_->rtcp_transport() != nullptr);
   channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release());
-  DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
+  transport_controller_->DestroyTransportChannel(
+      transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
   if (need_to_delete_rtcp) {
-    DestroyTransport(transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
+    transport_controller_->DestroyTransportChannel(
+        transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
   }
 }
 }  // namespace webrtc