Delete ConnectionMonitor.

Bug: webrtc:8760
Change-Id: I345659eebc04704bedd46e1b04959cd63785aa62
Reviewed-on: https://webrtc-review.googlesource.com/40201
Reviewed-by: Noah Richards <noahric@chromium.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21667}
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index 9ab79e4..814cea9 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -79,8 +79,6 @@
     "client/basicportallocator.cc",
     "client/basicportallocator.h",
     "client/relayportfactoryinterface.h",
-    "client/socketmonitor.cc",
-    "client/socketmonitor.h",
     "client/turnportfactory.cc",
     "client/turnportfactory.h",
   ]
diff --git a/p2p/client/socketmonitor.cc b/p2p/client/socketmonitor.cc
deleted file mode 100644
index 6bfa186..0000000
--- a/p2p/client/socketmonitor.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *  Copyright 2004 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "p2p/client/socketmonitor.h"
-
-#include "rtc_base/checks.h"
-
-namespace cricket {
-
-enum {
-  MSG_MONITOR_POLL,
-  MSG_MONITOR_START,
-  MSG_MONITOR_STOP,
-  MSG_MONITOR_SIGNAL
-};
-
-ConnectionMonitor::ConnectionMonitor(ConnectionStatsGetter* stats_getter,
-                                     rtc::Thread* network_thread,
-                                     rtc::Thread* monitoring_thread) {
-  stats_getter_ = stats_getter;
-  network_thread_ = network_thread;
-  monitoring_thread_ = monitoring_thread;
-  monitoring_ = false;
-}
-
-ConnectionMonitor::~ConnectionMonitor() {
-  network_thread_->Clear(this);
-  monitoring_thread_->Clear(this);
-}
-
-void ConnectionMonitor::Start(int milliseconds) {
-  rate_ = milliseconds;
-  if (rate_ < 250)
-    rate_ = 250;
-  network_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_START);
-}
-
-void ConnectionMonitor::Stop() {
-  network_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP);
-}
-
-void ConnectionMonitor::OnMessage(rtc::Message *message) {
-  rtc::CritScope cs(&crit_);
-  switch (message->message_id) {
-    case MSG_MONITOR_START:
-      RTC_DCHECK(rtc::Thread::Current() == network_thread_);
-      if (!monitoring_) {
-        monitoring_ = true;
-        PollConnectionStats_w();
-      }
-      break;
-
-    case MSG_MONITOR_STOP:
-      RTC_DCHECK(rtc::Thread::Current() == network_thread_);
-      if (monitoring_) {
-        monitoring_ = false;
-        network_thread_->Clear(this);
-      }
-      break;
-
-    case MSG_MONITOR_POLL:
-      RTC_DCHECK(rtc::Thread::Current() == network_thread_);
-      PollConnectionStats_w();
-      break;
-
-    case MSG_MONITOR_SIGNAL: {
-      RTC_DCHECK(rtc::Thread::Current() == monitoring_thread_);
-      std::vector<ConnectionInfo> infos = connection_infos_;
-      crit_.Leave();
-      SignalUpdate(this, infos);
-      crit_.Enter();
-      break;
-    }
-  }
-}
-
-void ConnectionMonitor::PollConnectionStats_w() {
-  RTC_DCHECK(rtc::Thread::Current() == network_thread_);
-  rtc::CritScope cs(&crit_);
-
-  // Gather connection infos
-  stats_getter_->GetConnectionStats(&connection_infos_);
-
-  // Signal the monitoring thread, start another poll timer
-  monitoring_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_SIGNAL);
-  network_thread_->PostDelayed(RTC_FROM_HERE, rate_, this, MSG_MONITOR_POLL);
-}
-
-}  // namespace cricket
diff --git a/p2p/client/socketmonitor.h b/p2p/client/socketmonitor.h
deleted file mode 100644
index 3428b03..0000000
--- a/p2p/client/socketmonitor.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *  Copyright 2004 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef P2P_CLIENT_SOCKETMONITOR_H_
-#define P2P_CLIENT_SOCKETMONITOR_H_
-
-#include <vector>
-
-#include "p2p/base/port.h"  // for ConnectionInfos
-#include "rtc_base/criticalsection.h"
-#include "rtc_base/sigslot.h"
-#include "rtc_base/thread.h"
-
-// TODO(pthatcher): Move these to connectionmonitor.h and
-// connectionmonitor.cc, or just move them into channel.cc
-
-namespace cricket {
-
-class ConnectionStatsGetter {
- public:
-  virtual ~ConnectionStatsGetter() {}
-  virtual bool GetConnectionStats(ConnectionInfos* infos) = 0;
-};
-
-class ConnectionMonitor : public rtc::MessageHandler,
-                          public sigslot::has_slots<> {
- public:
-  ConnectionMonitor(ConnectionStatsGetter* stats_getter,
-                    rtc::Thread* network_thread,
-                    rtc::Thread* monitoring_thread);
-  ~ConnectionMonitor() override;
-
-  void Start(int cms);
-  void Stop();
-
-  sigslot::signal2<ConnectionMonitor*,
-                   const std::vector<ConnectionInfo>&> SignalUpdate;
-
- protected:
-  void OnMessage(rtc::Message* message) override;
-
- private:
-  void PollConnectionStats_w();
-
-  std::vector<ConnectionInfo> connection_infos_;
-  ConnectionStatsGetter* stats_getter_;
-  rtc::Thread* network_thread_;
-  rtc::Thread* monitoring_thread_;
-  rtc::CriticalSection crit_;
-  uint32_t rate_;
-  bool monitoring_;
-};
-
-}  // namespace cricket
-
-#endif  // P2P_CLIENT_SOCKETMONITOR_H_
diff --git a/pc/channel.cc b/pc/channel.cc
index 954cdce..0c1434d 100644
--- a/pc/channel.cc
+++ b/pc/channel.cc
@@ -120,7 +120,6 @@
   TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel");
   RTC_DCHECK_RUN_ON(worker_thread_);
   Deinit();
-  StopConnectionMonitor();
   // Eats any outstanding messages or packets.
   worker_thread_->Clear(&invoker_);
   worker_thread_->Clear(this);
@@ -403,35 +402,6 @@
       Bind(&BaseChannel::SetRemoteContent_w, this, content, type, error_desc));
 }
 
-void BaseChannel::StartConnectionMonitor(int cms) {
-  // We pass in the BaseChannel instead of the rtp_dtls_transport_
-  // because if the rtp_dtls_transport_ changes, the ConnectionMonitor
-  // would be pointing to the wrong TransportChannel.
-  // We pass in the network thread because on that thread connection monitor
-  // will call BaseChannel::GetConnectionStats which must be called on the
-  // network thread.
-  connection_monitor_.reset(
-      new ConnectionMonitor(this, network_thread(), rtc::Thread::Current()));
-  connection_monitor_->SignalUpdate.connect(
-      this, &BaseChannel::OnConnectionMonitorUpdate);
-  connection_monitor_->Start(cms);
-}
-
-void BaseChannel::StopConnectionMonitor() {
-  if (connection_monitor_) {
-    connection_monitor_->Stop();
-    connection_monitor_.reset();
-  }
-}
-
-bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) {
-  RTC_DCHECK(network_thread_->IsCurrent());
-  if (!rtp_dtls_transport_) {
-    return false;
-  }
-  return rtp_dtls_transport_->ice_transport()->GetStats(infos);
-}
-
 bool BaseChannel::NeedsRtcpTransport() {
   // If this BaseChannel doesn't require RTCP mux and we haven't fully
   // negotiated RTCP mux, we need an RTCP transport.
@@ -1397,11 +1367,6 @@
   }
 }
 
-void VoiceChannel::OnConnectionMonitorUpdate(
-    ConnectionMonitor* monitor, const std::vector<ConnectionInfo>& infos) {
-  SignalConnectionMonitor(this, infos);
-}
-
 VideoChannel::VideoChannel(rtc::Thread* worker_thread,
                            rtc::Thread* network_thread,
                            rtc::Thread* signaling_thread,
@@ -1553,11 +1518,6 @@
   return true;
 }
 
-void VideoChannel::OnConnectionMonitorUpdate(
-    ConnectionMonitor* monitor, const std::vector<ConnectionInfo> &infos) {
-  SignalConnectionMonitor(this, infos);
-}
-
 RtpDataChannel::RtpDataChannel(rtc::Thread* worker_thread,
                                rtc::Thread* network_thread,
                                rtc::Thread* signaling_thread,
@@ -1780,12 +1740,6 @@
   }
 }
 
-void RtpDataChannel::OnConnectionMonitorUpdate(
-    ConnectionMonitor* monitor,
-    const std::vector<ConnectionInfo>& infos) {
-  SignalConnectionMonitor(this, infos);
-}
-
 void RtpDataChannel::OnDataReceived(const ReceiveDataParams& params,
                                     const char* data,
                                     size_t len) {
diff --git a/pc/channel.h b/pc/channel.h
index 75299d5..00747eb 100644
--- a/pc/channel.h
+++ b/pc/channel.h
@@ -28,7 +28,6 @@
 #include "media/base/streamparams.h"
 #include "p2p/base/dtlstransportinternal.h"
 #include "p2p/base/packettransportinternal.h"
-#include "p2p/client/socketmonitor.h"
 #include "pc/audiomonitor.h"
 #include "pc/dtlssrtptransport.h"
 #include "pc/mediasession.h"
@@ -72,8 +71,7 @@
 
 class BaseChannel
     : public rtc::MessageHandler, public sigslot::has_slots<>,
-      public MediaChannel::NetworkInterface,
-      public ConnectionStatsGetter {
+      public MediaChannel::NetworkInterface {
  public:
   // If |srtp_required| is true, the channel will not send or receive any
   // RTP/RTCP packets without using SRTP (either using SDES or DTLS-SRTP).
@@ -153,12 +151,6 @@
   bool AddSendStream(const StreamParams& sp);
   bool RemoveSendStream(uint32_t ssrc);
 
-  // Monitoring
-  void StartConnectionMonitor(int cms);
-  void StopConnectionMonitor();
-  // For ConnectionStatsGetter, used by ConnectionMonitor
-  bool GetConnectionStats(ConnectionInfos* infos) override;
-
   const std::vector<StreamParams>& local_streams() const {
     return local_streams_;
   }
@@ -357,10 +349,6 @@
   // From MessageHandler
   void OnMessage(rtc::Message* pmsg) override;
 
-  // Handled in derived classes
-  virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor,
-      const std::vector<ConnectionInfo>& infos) = 0;
-
   // Helper function template for invoking methods on the worker thread.
   template <class T, class FunctorT>
   T InvokeOnWorker(const rtc::Location& posted_from, const FunctorT& functor) {
@@ -401,7 +389,6 @@
   rtc::AsyncInvoker invoker_;
 
   const std::string content_name_;
-  std::unique_ptr<ConnectionMonitor> connection_monitor_;
 
   // Won't be set when using raw packet transports. SDP-specific thing.
   std::string transport_name_;
@@ -485,9 +472,6 @@
   bool GetStats(VoiceMediaInfo* stats);
 
   // Monitoring functions
-  sigslot::signal2<VoiceChannel*, const std::vector<ConnectionInfo>&>
-      SignalConnectionMonitor;
-
   void StartAudioMonitor(int cms);
   void StopAudioMonitor();
   bool IsAudioMonitorRunning() const;
@@ -514,9 +498,6 @@
   void HandleEarlyMediaTimeout();
 
   void OnMessage(rtc::Message* pmsg) override;
-  void OnConnectionMonitorUpdate(
-      ConnectionMonitor* monitor,
-      const std::vector<ConnectionInfo>& infos) override;
 
   static const int kEarlyMediaTimeout = 1000;
   MediaEngineInterface* media_engine_;
@@ -552,9 +533,6 @@
   // Get statistics about the current media session.
   bool GetStats(VideoMediaInfo* stats);
 
-  sigslot::signal2<VideoChannel*, const std::vector<ConnectionInfo>&>
-      SignalConnectionMonitor;
-
   cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_VIDEO; }
 
  private:
@@ -568,10 +546,6 @@
                           std::string* error_desc) override;
   bool GetStats_w(VideoMediaInfo* stats);
 
-  void OnConnectionMonitorUpdate(
-      ConnectionMonitor* monitor,
-      const std::vector<ConnectionInfo>& infos) override;
-
   // Last VideoSendParameters sent down to the media_channel() via
   // SetSendParameters.
   VideoSendParameters last_send_params_;
@@ -608,9 +582,6 @@
     return ready_to_send_data_;
   }
 
-  sigslot::signal2<RtpDataChannel*, const std::vector<ConnectionInfo>&>
-      SignalConnectionMonitor;
-
   sigslot::signal2<const ReceiveDataParams&, const rtc::CopyOnWriteBuffer&>
       SignalDataReceived;
   // Signal for notifying when the channel becomes ready to send data.
@@ -670,9 +641,6 @@
   void UpdateMediaSendRecvState_w() override;
 
   void OnMessage(rtc::Message* pmsg) override;
-  void OnConnectionMonitorUpdate(
-      ConnectionMonitor* monitor,
-      const std::vector<ConnectionInfo>& infos) override;
   void OnDataReceived(
       const ReceiveDataParams& params, const char* data, size_t len);
   void OnDataChannelReadyToSend(bool writable);