Enable the clang style plugin in primary p2p/ target

Bug: webrtc:163
Change-Id: I318982ee549fe71cd48f74cdfad4173506742411
Reviewed-on: https://webrtc-review.googlesource.com/17040
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20509}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 72078b4..bad3a51 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -53,6 +53,7 @@
     "notifier.h",
     "peerconnectionfactoryproxy.h",
     "peerconnectionproxy.h",
+    "proxy.cc",
     "proxy.h",
     "rtcerror.cc",
     "rtcerror.h",
@@ -63,6 +64,7 @@
     "statstypes.cc",
     "statstypes.h",
     "turncustomizer.h",
+    "umametrics.cc",
     "umametrics.h",
     "videosourceproxy.h",
   ]
diff --git a/api/proxy.cc b/api/proxy.cc
new file mode 100644
index 0000000..c86bddf
--- /dev/null
+++ b/api/proxy.cc
@@ -0,0 +1,38 @@
+/*
+ *  Copyright 2017 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 "api/proxy.h"
+
+namespace webrtc {
+namespace internal {
+
+SynchronousMethodCall::SynchronousMethodCall(rtc::MessageHandler* proxy)
+    : e_(), proxy_(proxy) {}
+
+SynchronousMethodCall::~SynchronousMethodCall() = default;
+
+void SynchronousMethodCall::Invoke(const rtc::Location& posted_from,
+                                   rtc::Thread* t) {
+  if (t->IsCurrent()) {
+    proxy_->OnMessage(nullptr);
+  } else {
+    e_.reset(new rtc::Event(false, false));
+    t->Post(posted_from, this, 0);
+    e_->Wait(rtc::Event::kForever);
+  }
+}
+
+void SynchronousMethodCall::OnMessage(rtc::Message*) {
+  proxy_->OnMessage(nullptr);
+  e_->Set();
+}
+
+}  // namespace internal
+}  // namespace webrtc
diff --git a/api/proxy.h b/api/proxy.h
index 175c6b7..dd7182e 100644
--- a/api/proxy.h
+++ b/api/proxy.h
@@ -123,25 +123,14 @@
     : public rtc::MessageData,
       public rtc::MessageHandler {
  public:
-  explicit SynchronousMethodCall(rtc::MessageHandler* proxy)
-      : e_(), proxy_(proxy) {}
-  ~SynchronousMethodCall() {}
+  explicit SynchronousMethodCall(rtc::MessageHandler* proxy);
+  ~SynchronousMethodCall() override;
 
-  void Invoke(const rtc::Location& posted_from, rtc::Thread* t) {
-    if (t->IsCurrent()) {
-      proxy_->OnMessage(nullptr);
-    } else {
-      e_.reset(new rtc::Event(false, false));
-      t->Post(posted_from, this, 0);
-      e_->Wait(rtc::Event::kForever);
-    }
-  }
+  void Invoke(const rtc::Location& posted_from, rtc::Thread* t);
 
  private:
-  void OnMessage(rtc::Message*) {
-    proxy_->OnMessage(nullptr);
-    e_->Set();
-  }
+  void OnMessage(rtc::Message*) override;
+
   std::unique_ptr<rtc::Event> e_;
   rtc::MessageHandler* proxy_;
 };
diff --git a/api/umametrics.cc b/api/umametrics.cc
new file mode 100644
index 0000000..d5f2bb6
--- /dev/null
+++ b/api/umametrics.cc
@@ -0,0 +1,21 @@
+/*
+ *  Copyright 2017 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 "api/umametrics.h"
+
+namespace webrtc {
+
+void MetricsObserverInterface::IncrementSparseEnumCounter(
+    PeerConnectionEnumCounterType type,
+    int counter) {
+  IncrementEnumCounter(type, counter, 0 /* Ignored */);
+}
+
+}  // namespace webrtc
diff --git a/api/umametrics.h b/api/umametrics.h
index 825950d..c512598 100644
--- a/api/umametrics.h
+++ b/api/umametrics.h
@@ -124,15 +124,10 @@
   // TODO(guoweis): Remove the implementation once the dependency's interface
   // definition is updated.
   virtual void IncrementSparseEnumCounter(PeerConnectionEnumCounterType type,
-                                          int counter) {
-    IncrementEnumCounter(type, counter, 0 /* Ignored */);
-  }
+                                          int counter);
 
   virtual void AddHistogramSample(PeerConnectionMetricsName type,
                                   int value) = 0;
-
- protected:
-  virtual ~MetricsObserverInterface() {}
 };
 
 typedef MetricsObserverInterface UMAObserver;
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index dba5577..f3dc27d 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -115,11 +115,6 @@
       "FEATURE_ENABLE_VOICEMAIL",
       "FEATURE_ENABLE_PSTN",
     ]
-
-    if (!build_with_chromium && is_clang) {
-      # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
-      suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
-    }
   }
 }
 
diff --git a/p2p/base/asyncstuntcpsocket.h b/p2p/base/asyncstuntcpsocket.h
index 0ff179d..15ca911 100644
--- a/p2p/base/asyncstuntcpsocket.h
+++ b/p2p/base/asyncstuntcpsocket.h
@@ -28,12 +28,12 @@
       const rtc::SocketAddress& remote_address);
 
   AsyncStunTCPSocket(rtc::AsyncSocket* socket, bool listen);
-  virtual ~AsyncStunTCPSocket() {}
 
-  virtual int Send(const void* pv, size_t cb,
-                   const rtc::PacketOptions& options);
-  virtual void ProcessInput(char* data, size_t* len);
-  virtual void HandleIncomingConnection(rtc::AsyncSocket* socket);
+  int Send(const void* pv,
+           size_t cb,
+           const rtc::PacketOptions& options) override;
+  void ProcessInput(char* data, size_t* len) override;
+  void HandleIncomingConnection(rtc::AsyncSocket* socket) override;
 
  private:
   // This method returns the message hdr + length written in the header.
diff --git a/p2p/base/jseptransport.cc b/p2p/base/jseptransport.cc
index fbb6287..ad84e47 100644
--- a/p2p/base/jseptransport.cc
+++ b/p2p/base/jseptransport.cc
@@ -64,6 +64,45 @@
       nominated(false),
       total_round_trip_time_ms(0) {}
 
+ConnectionInfo::ConnectionInfo(const ConnectionInfo&) = default;
+
+ConnectionInfo::~ConnectionInfo() = default;
+
+TransportChannelStats::TransportChannelStats() = default;
+
+TransportChannelStats::TransportChannelStats(const TransportChannelStats&) =
+    default;
+
+TransportChannelStats::~TransportChannelStats() = default;
+
+TransportStats::TransportStats() = default;
+
+TransportStats::~TransportStats() = default;
+
+IceConfig::IceConfig() = default;
+
+IceConfig::IceConfig(int receiving_timeout_ms,
+                     int backup_connection_ping_interval,
+                     ContinualGatheringPolicy gathering_policy,
+                     bool prioritize_most_likely_candidate_pairs,
+                     int stable_writable_connection_ping_interval_ms,
+                     bool presume_writable_when_fully_relayed,
+                     int regather_on_failed_networks_interval_ms,
+                     int receiving_switching_delay_ms)
+    : receiving_timeout(receiving_timeout_ms),
+      backup_connection_ping_interval(backup_connection_ping_interval),
+      continual_gathering_policy(gathering_policy),
+      prioritize_most_likely_candidate_pairs(
+          prioritize_most_likely_candidate_pairs),
+      stable_writable_connection_ping_interval(
+          stable_writable_connection_ping_interval_ms),
+      presume_writable_when_fully_relayed(presume_writable_when_fully_relayed),
+      regather_on_failed_networks_interval(
+          regather_on_failed_networks_interval_ms),
+      receiving_switching_delay(receiving_switching_delay_ms) {}
+
+IceConfig::~IceConfig() = default;
+
 bool BadTransportDescription(const std::string& desc, std::string* err_desc) {
   if (err_desc) {
     *err_desc = desc;
@@ -128,6 +167,8 @@
     const rtc::scoped_refptr<rtc::RTCCertificate>& certificate)
     : mid_(mid), certificate_(certificate) {}
 
+JsepTransport::~JsepTransport() = default;
+
 bool JsepTransport::AddChannel(DtlsTransportInternal* dtls, int component) {
   if (channels_.find(component) != channels_.end()) {
     LOG(LS_ERROR) << "Adding channel for component " << component << " twice.";
diff --git a/p2p/base/jseptransport.h b/p2p/base/jseptransport.h
index 4cf9695..7277e1b 100644
--- a/p2p/base/jseptransport.h
+++ b/p2p/base/jseptransport.h
@@ -84,6 +84,8 @@
 // TODO(hta): Rename to ConnectionStats
 struct ConnectionInfo {
   ConnectionInfo();
+  ConnectionInfo(const ConnectionInfo&);
+  ~ConnectionInfo();
 
   bool best_connection;      // Is this the best connection we have?
   bool writable;             // Has this connection received a STUN response?
@@ -126,6 +128,10 @@
 
 // Information about a specific channel
 struct TransportChannelStats {
+  TransportChannelStats();
+  TransportChannelStats(const TransportChannelStats&);
+  ~TransportChannelStats();
+
   int component = 0;
   ConnectionInfos connection_infos;
   int srtp_crypto_suite = rtc::SRTP_INVALID_CRYPTO_SUITE;
@@ -139,6 +145,9 @@
 
 // Information about the stats of a transport.
 struct TransportStats {
+  TransportStats();
+  ~TransportStats();
+
   std::string transport_name;
   TransportChannelStatsList channel_stats;
 };
@@ -202,7 +211,7 @@
   // Measure in milliseconds.
   rtc::Optional<int> ice_check_min_interval;
 
-  IceConfig() {}
+  IceConfig();
   IceConfig(int receiving_timeout_ms,
             int backup_connection_ping_interval,
             ContinualGatheringPolicy gathering_policy,
@@ -210,19 +219,8 @@
             int stable_writable_connection_ping_interval_ms,
             bool presume_writable_when_fully_relayed,
             int regather_on_failed_networks_interval_ms,
-            int receiving_switching_delay_ms)
-      : receiving_timeout(receiving_timeout_ms),
-        backup_connection_ping_interval(backup_connection_ping_interval),
-        continual_gathering_policy(gathering_policy),
-        prioritize_most_likely_candidate_pairs(
-            prioritize_most_likely_candidate_pairs),
-        stable_writable_connection_ping_interval(
-            stable_writable_connection_ping_interval_ms),
-        presume_writable_when_fully_relayed(
-            presume_writable_when_fully_relayed),
-        regather_on_failed_networks_interval(
-            regather_on_failed_networks_interval_ms),
-        receiving_switching_delay(receiving_switching_delay_ms) {}
+            int receiving_switching_delay_ms);
+  ~IceConfig();
 };
 
 bool BadTransportDescription(const std::string& desc, std::string* err_desc);
@@ -254,6 +252,7 @@
   // may be set before a local certificate is generated.
   JsepTransport(const std::string& mid,
                 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
+  ~JsepTransport() override;
 
   // Returns the MID of this transport.
   const std::string& mid() const { return mid_; }
diff --git a/p2p/base/packetlossestimator.cc b/p2p/base/packetlossestimator.cc
index d146c8a..ae05ff5 100644
--- a/p2p/base/packetlossestimator.cc
+++ b/p2p/base/packetlossestimator.cc
@@ -23,6 +23,8 @@
   RTC_DCHECK_LT(consider_lost_after_ms, forget_after_ms);
 }
 
+PacketLossEstimator::~PacketLossEstimator() = default;
+
 void PacketLossEstimator::ExpectResponse(std::string id, int64_t sent_time) {
   tracked_packets_[id] = PacketInfo{sent_time, false};
 
diff --git a/p2p/base/packetlossestimator.h b/p2p/base/packetlossestimator.h
index 8b8bb2b..2256bdd 100644
--- a/p2p/base/packetlossestimator.h
+++ b/p2p/base/packetlossestimator.h
@@ -39,6 +39,7 @@
  public:
   explicit PacketLossEstimator(int64_t consider_lost_after_ms,
                                int64_t forget_after_ms);
+  ~PacketLossEstimator();
 
   // Registers that a message with the given |id| was sent at |sent_time|.
   void ExpectResponse(std::string id, int64_t sent_time);
diff --git a/p2p/base/port.cc b/p2p/base/port.cc
index b16c3ea..f742dee 100644
--- a/p2p/base/port.cc
+++ b/p2p/base/port.cc
@@ -172,6 +172,15 @@
            const std::string& type,
            rtc::PacketSocketFactory* factory,
            rtc::Network* network,
+           const rtc::IPAddress& ip,
+           const std::string& username_fragment,
+           const std::string& password)
+    : Port(thread, type, factory, network, username_fragment, password) {}
+
+Port::Port(rtc::Thread* thread,
+           const std::string& type,
+           rtc::PacketSocketFactory* factory,
+           rtc::Network* network,
            uint16_t min_port,
            uint16_t max_port,
            const std::string& username_fragment,
diff --git a/p2p/base/port.h b/p2p/base/port.h
index e7254e8..3bcfae2 100644
--- a/p2p/base/port.h
+++ b/p2p/base/port.h
@@ -151,8 +151,7 @@
        rtc::Network* network,
        const rtc::IPAddress& ip,
        const std::string& username_fragment,
-       const std::string& password)
-      : Port(thread, type, factory, network, username_fragment, password) {}
+       const std::string& password);
   Port(rtc::Thread* thread,
        const std::string& type,
        rtc::PacketSocketFactory* factory,
diff --git a/p2p/base/relayserver.h b/p2p/base/relayserver.h
index 1b299bf..9dbf668 100644
--- a/p2p/base/relayserver.h
+++ b/p2p/base/relayserver.h
@@ -34,7 +34,7 @@
  public:
   // Creates a server, which will use this thread to post messages to itself.
   explicit RelayServer(rtc::Thread* thread);
-  ~RelayServer();
+  ~RelayServer() override;
 
   rtc::Thread* thread() { return thread_; }
 
@@ -116,7 +116,7 @@
   void RemoveBinding(RelayServerBinding* binding);
 
   // Handle messages in our thread.
-  void OnMessage(rtc::Message *pmsg);
+  void OnMessage(rtc::Message* pmsg) override;
 
   // Called when the timer for checking lifetime times out.
   void OnTimeout(RelayServerBinding* binding);
@@ -185,7 +185,7 @@
                      const std::string& username,
                      const std::string& password,
                      int lifetime);
-  virtual ~RelayServerBinding();
+  ~RelayServerBinding() override;
 
   RelayServer* server() { return server_; }
   int lifetime() { return lifetime_; }
@@ -214,7 +214,7 @@
       const rtc::SocketAddress& ext_addr);
 
   // MessageHandler:
-  void OnMessage(rtc::Message *pmsg);
+  void OnMessage(rtc::Message* pmsg) override;
 
  private:
   RelayServer* server_;
diff --git a/p2p/base/stunrequest.h b/p2p/base/stunrequest.h
index e77242e..7bb0466 100644
--- a/p2p/base/stunrequest.h
+++ b/p2p/base/stunrequest.h
@@ -84,7 +84,7 @@
  public:
   StunRequest();
   StunRequest(StunMessage* request);
-  virtual ~StunRequest();
+  ~StunRequest() override;
 
   // Causes our wrapped StunMessage to be Prepared
   void Construct();
@@ -133,7 +133,7 @@
   void set_manager(StunRequestManager* manager);
 
   // Handles messages for sending and timeout.
-  void OnMessage(rtc::Message* pmsg);
+  void OnMessage(rtc::Message* pmsg) override;
 
   StunRequestManager* manager_;
   StunMessage* msg_;
diff --git a/p2p/base/turnserver.cc b/p2p/base/turnserver.cc
index 0f7d815..62a381a 100644
--- a/p2p/base/turnserver.cc
+++ b/p2p/base/turnserver.cc
@@ -61,7 +61,7 @@
 class TurnServerAllocation::Permission : public rtc::MessageHandler {
  public:
   Permission(rtc::Thread* thread, const rtc::IPAddress& peer);
-  ~Permission();
+  ~Permission() override;
 
   const rtc::IPAddress& peer() const { return peer_; }
   void Refresh();
@@ -69,7 +69,7 @@
   sigslot::signal1<Permission*> SignalDestroyed;
 
  private:
-  virtual void OnMessage(rtc::Message* msg);
+  void OnMessage(rtc::Message* msg) override;
 
   rtc::Thread* thread_;
   rtc::IPAddress peer_;
@@ -82,7 +82,7 @@
  public:
   Channel(rtc::Thread* thread, int id,
                      const rtc::SocketAddress& peer);
-  ~Channel();
+  ~Channel() override;
 
   int id() const { return id_; }
   const rtc::SocketAddress& peer() const { return peer_; }
@@ -91,7 +91,7 @@
   sigslot::signal1<Channel*> SignalDestroyed;
 
  private:
-  virtual void OnMessage(rtc::Message* msg);
+  void OnMessage(rtc::Message* msg) override;
 
   rtc::Thread* thread_;
   int id_;
diff --git a/p2p/base/turnserver.h b/p2p/base/turnserver.h
index f694912..8953484 100644
--- a/p2p/base/turnserver.h
+++ b/p2p/base/turnserver.h
@@ -73,7 +73,7 @@
                        const TurnServerConnection& conn,
                        rtc::AsyncPacketSocket* server_socket,
                        const std::string& key);
-  virtual ~TurnServerAllocation();
+  ~TurnServerAllocation() override;
 
   TurnServerConnection* conn() { return &conn_; }
   const std::string& key() const { return key_; }
@@ -123,7 +123,7 @@
 
   void OnPermissionDestroyed(Permission* perm);
   void OnChannelDestroyed(Channel* channel);
-  virtual void OnMessage(rtc::Message* msg);
+  void OnMessage(rtc::Message* msg) override;
 
   TurnServer* server_;
   rtc::Thread* thread_;
@@ -174,7 +174,7 @@
       AllocationMap;
 
   explicit TurnServer(rtc::Thread* thread);
-  ~TurnServer();
+  ~TurnServer() override;
 
   // Gets/sets the realm value to use for the server.
   const std::string& realm() const { return realm_; }
diff --git a/p2p/client/socketmonitor.h b/p2p/client/socketmonitor.h
index 57c6d72..1698a79 100644
--- a/p2p/client/socketmonitor.h
+++ b/p2p/client/socketmonitor.h
@@ -35,7 +35,7 @@
   ConnectionMonitor(ConnectionStatsGetter* stats_getter,
                     rtc::Thread* network_thread,
                     rtc::Thread* monitoring_thread);
-  ~ConnectionMonitor();
+  ~ConnectionMonitor() override;
 
   void Start(int cms);
   void Stop();
@@ -44,7 +44,8 @@
                    const std::vector<ConnectionInfo>&> SignalUpdate;
 
  protected:
-  void OnMessage(rtc::Message* message);
+  void OnMessage(rtc::Message* message) override;
+
  private:
   void PollConnectionStats_w();