Modernize and cleanup ChannelManager

Bug: None
Change-Id: Ifd07c10dc1d3655e0138900c9a9897810cec3d54
Reviewed-on: https://webrtc-review.googlesource.com/18080
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20593}
diff --git a/pc/channelmanager.h b/pc/channelmanager.h
index 94d1e0a..9f55f0e 100644
--- a/pc/channelmanager.h
+++ b/pc/channelmanager.h
@@ -16,13 +16,11 @@
 #include <vector>
 
 #include "media/base/mediaengine.h"
-#include "pc/voicechannel.h"
+#include "pc/channel.h"
 #include "rtc_base/thread.h"
 
 namespace cricket {
 
-class VoiceChannel;
-
 // ChannelManager allows the MediaEngine to run on a separate thread, and takes
 // care of marshalling calls between threads. It also creates and keeps track of
 // voice and video channels; by doing so, it can temporarily pause all the
@@ -31,17 +29,13 @@
 // voice or just video channels.
 // ChannelManager also allows the application to discover what devices it has
 // using device manager.
-class ChannelManager {
+class ChannelManager final {
  public:
-  // For testing purposes. Allows the media engine and data media
-  // engine and dev manager to be mocks.
-  ChannelManager(std::unique_ptr<MediaEngineInterface> me,
-                 std::unique_ptr<DataEngineInterface> dme,
-                 rtc::Thread* worker_and_network);
-  // Same as above, but gives an easier default DataEngine.
-  ChannelManager(std::unique_ptr<MediaEngineInterface> me,
-                 rtc::Thread* worker,
-                 rtc::Thread* network);
+  // Construct a ChannelManager with the specified media engine and data engine.
+  ChannelManager(std::unique_ptr<MediaEngineInterface> media_engine,
+                 std::unique_ptr<DataEngineInterface> data_engine,
+                 rtc::Thread* worker_thread,
+                 rtc::Thread* network_thread);
   ~ChannelManager();
 
   // Accessors for the worker thread, allowing it to be set after construction,
@@ -144,7 +138,8 @@
 
   // Indicates whether any channels exist.
   bool has_channels() const {
-    return (!voice_channels_.empty() || !video_channels_.empty());
+    return (!voice_channels_.empty() || !video_channels_.empty() ||
+            !data_channels_.empty());
   }
 
   // RTX will be enabled/disabled in engines that support it. The supporting
@@ -165,13 +160,6 @@
   void StopAecDump();
 
  private:
-  void Construct(std::unique_ptr<MediaEngineInterface> me,
-                 std::unique_ptr<DataEngineInterface> dme,
-                 rtc::Thread* worker_thread,
-                 rtc::Thread* network_thread);
-  bool InitMediaEngine_w();
-  void DestructorDeletes_w();
-  void Terminate_w();
   VoiceChannel* CreateVoiceChannel_w(
       webrtc::Call* call,
       const cricket::MediaConfig& media_config,
@@ -183,7 +171,6 @@
       const std::string& content_name,
       bool srtp_required,
       const AudioOptions& options);
-  void DestroyVoiceChannel_w(VoiceChannel* voice_channel);
   VideoChannel* CreateVideoChannel_w(
       webrtc::Call* call,
       const cricket::MediaConfig& media_config,
@@ -195,29 +182,21 @@
       const std::string& content_name,
       bool srtp_required,
       const VideoOptions& options);
-  void DestroyVideoChannel_w(VideoChannel* video_channel);
-  RtpDataChannel* CreateRtpDataChannel_w(
-      const cricket::MediaConfig& media_config,
-      DtlsTransportInternal* rtp_transport,
-      DtlsTransportInternal* rtcp_transport,
-      rtc::Thread* signaling_thread,
-      const std::string& content_name,
-      bool srtp_required);
-  void DestroyRtpDataChannel_w(RtpDataChannel* data_channel);
 
-  std::unique_ptr<MediaEngineInterface> media_engine_;
-  std::unique_ptr<DataEngineInterface> data_media_engine_;
-  bool initialized_;
+  std::unique_ptr<MediaEngineInterface> media_engine_;  // Nullable.
+  std::unique_ptr<DataEngineInterface> data_engine_;    // Non-null.
+  bool initialized_ = false;
   rtc::Thread* main_thread_;
   rtc::Thread* worker_thread_;
   rtc::Thread* network_thread_;
 
+  // Vector contents are non-null.
   std::vector<std::unique_ptr<VoiceChannel>> voice_channels_;
   std::vector<std::unique_ptr<VideoChannel>> video_channels_;
   std::vector<std::unique_ptr<RtpDataChannel>> data_channels_;
 
-  bool enable_rtx_;
-  bool capturing_;
+  bool enable_rtx_ = false;
+  bool capturing_ = false;
 };
 
 }  // namespace cricket