Enable the clang style plugin for the stunprober target

Bug: webrtc:163
Change-Id: I77c92dfc05626cb5e83d4e93d735c1370ed4af23
Reviewed-on: https://webrtc-review.googlesource.com/15783
Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20435}
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index ff558a9..22286c4 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -129,6 +129,7 @@
       "base/fakeportallocator.h",
       "base/mockicetransport.h",
       "base/testrelayserver.h",
+      "base/teststunserver.cc",
       "base/teststunserver.h",
       "base/testturncustomizer.h",
       "base/testturnserver.h",
@@ -201,12 +202,6 @@
     "stunprober/stunprober.h",
   ]
 
-  if (!build_with_chromium && is_clang) {
-    # Suppress warnings from Chrome's Clang plugins.
-    # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
-    suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
-  }
-
   deps = [
     ":rtc_p2p",
     "..:webrtc_common",
@@ -236,10 +231,6 @@
       "//testing/gmock",
       "//testing/gtest",
     ]
-    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" ]
-    }
     defines = [ "GTEST_RELATIVE_PATH" ]
   }
 }
diff --git a/p2p/base/basicpacketsocketfactory.cc b/p2p/base/basicpacketsocketfactory.cc
index eb36bc2..7438a9b 100644
--- a/p2p/base/basicpacketsocketfactory.cc
+++ b/p2p/base/basicpacketsocketfactory.cc
@@ -109,6 +109,18 @@
     const SocketAddress& remote_address,
     const ProxyInfo& proxy_info,
     const std::string& user_agent,
+    int opts) {
+  PacketSocketTcpOptions tcp_options;
+  tcp_options.opts = opts;
+  return CreateClientTcpSocket(local_address, remote_address, proxy_info,
+                               user_agent, tcp_options);
+}
+
+AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket(
+    const SocketAddress& local_address,
+    const SocketAddress& remote_address,
+    const ProxyInfo& proxy_info,
+    const std::string& user_agent,
     const PacketSocketTcpOptions& tcp_options) {
   AsyncSocket* socket =
       socket_factory()->CreateAsyncSocket(local_address.family(), SOCK_STREAM);
diff --git a/p2p/base/basicpacketsocketfactory.h b/p2p/base/basicpacketsocketfactory.h
index b3ae2f0..08f525e 100644
--- a/p2p/base/basicpacketsocketfactory.h
+++ b/p2p/base/basicpacketsocketfactory.h
@@ -37,12 +37,7 @@
                                            const SocketAddress& remote_address,
                                            const ProxyInfo& proxy_info,
                                            const std::string& user_agent,
-                                           int opts) override {
-    PacketSocketTcpOptions tcp_options;
-    tcp_options.opts = opts;
-    return CreateClientTcpSocket(local_address, remote_address, proxy_info,
-                                 user_agent, tcp_options);
-  }
+                                           int opts) override;
   AsyncPacketSocket* CreateClientTcpSocket(
       const SocketAddress& local_address,
       const SocketAddress& remote_address,
diff --git a/p2p/base/packetsocketfactory.h b/p2p/base/packetsocketfactory.h
index 9e43e9a..df4a19d 100644
--- a/p2p/base/packetsocketfactory.h
+++ b/p2p/base/packetsocketfactory.h
@@ -18,11 +18,17 @@
 
 // This structure contains options required to create TCP packet sockets.
 struct PacketSocketTcpOptions {
+  PacketSocketTcpOptions();
+  ~PacketSocketTcpOptions();
+
   int opts;
   std::vector<std::string> tls_alpn_protocols;
   std::vector<std::string> tls_elliptic_curves;
 };
 
+inline PacketSocketTcpOptions::PacketSocketTcpOptions() = default;
+inline PacketSocketTcpOptions::~PacketSocketTcpOptions() = default;
+
 class AsyncPacketSocket;
 class AsyncResolverInterface;
 
@@ -70,10 +76,7 @@
       const SocketAddress& remote_address,
       const ProxyInfo& proxy_info,
       const std::string& user_agent,
-      const PacketSocketTcpOptions& tcp_options) {
-    return CreateClientTcpSocket(local_address, remote_address, proxy_info,
-                                 user_agent, tcp_options.opts);
-  }
+      const PacketSocketTcpOptions& tcp_options);
 
   virtual AsyncResolverInterface* CreateAsyncResolver() = 0;
 
@@ -81,6 +84,16 @@
   RTC_DISALLOW_COPY_AND_ASSIGN(PacketSocketFactory);
 };
 
+inline AsyncPacketSocket* PacketSocketFactory::CreateClientTcpSocket(
+    const SocketAddress& local_address,
+    const SocketAddress& remote_address,
+    const ProxyInfo& proxy_info,
+    const std::string& user_agent,
+    const PacketSocketTcpOptions& tcp_options) {
+  return CreateClientTcpSocket(local_address, remote_address, proxy_info,
+                               user_agent, tcp_options.opts);
+}
+
 }  // namespace rtc
 
 #endif  // P2P_BASE_PACKETSOCKETFACTORY_H_
diff --git a/p2p/base/teststunserver.cc b/p2p/base/teststunserver.cc
new file mode 100644
index 0000000..13bc577
--- /dev/null
+++ b/p2p/base/teststunserver.cc
@@ -0,0 +1,35 @@
+/*
+ *  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 "p2p/base/teststunserver.h"
+
+namespace cricket {
+
+TestStunServer* TestStunServer::Create(rtc::Thread* thread,
+                                       const rtc::SocketAddress& addr) {
+  rtc::AsyncSocket* socket =
+      thread->socketserver()->CreateAsyncSocket(addr.family(), SOCK_DGRAM);
+  rtc::AsyncUDPSocket* udp_socket = rtc::AsyncUDPSocket::Create(socket, addr);
+
+  return new TestStunServer(udp_socket);
+}
+
+void TestStunServer::OnBindingRequest(StunMessage* msg,
+                                      const rtc::SocketAddress& remote_addr) {
+  if (fake_stun_addr_.IsNil()) {
+    StunServer::OnBindingRequest(msg, remote_addr);
+  } else {
+    StunMessage response;
+    GetStunBindReqponse(msg, fake_stun_addr_, &response);
+    SendResponse(response, remote_addr);
+  }
+}
+
+}  // namespace cricket
diff --git a/p2p/base/teststunserver.h b/p2p/base/teststunserver.h
index 7b3f098..4992640 100644
--- a/p2p/base/teststunserver.h
+++ b/p2p/base/teststunserver.h
@@ -21,14 +21,7 @@
 class TestStunServer : StunServer {
  public:
   static TestStunServer* Create(rtc::Thread* thread,
-                                const rtc::SocketAddress& addr) {
-    rtc::AsyncSocket* socket =
-        thread->socketserver()->CreateAsyncSocket(addr.family(), SOCK_DGRAM);
-    rtc::AsyncUDPSocket* udp_socket =
-        rtc::AsyncUDPSocket::Create(socket, addr);
-
-    return new TestStunServer(udp_socket);
-  }
+                                const rtc::SocketAddress& addr);
 
   // Set a fake STUN address to return to the client.
   void set_fake_stun_addr(const rtc::SocketAddress& addr) {
@@ -39,15 +32,7 @@
   explicit TestStunServer(rtc::AsyncUDPSocket* socket) : StunServer(socket) {}
 
   void OnBindingRequest(StunMessage* msg,
-                        const rtc::SocketAddress& remote_addr) override {
-    if (fake_stun_addr_.IsNil()) {
-      StunServer::OnBindingRequest(msg, remote_addr);
-    } else {
-      StunMessage response;
-      GetStunBindReqponse(msg, fake_stun_addr_, &response);
-      SendResponse(response, remote_addr);
-    }
-  }
+                        const rtc::SocketAddress& remote_addr) override;
 
  private:
   rtc::SocketAddress fake_stun_addr_;
diff --git a/p2p/stunprober/stunprober.cc b/p2p/stunprober/stunprober.cc
index 47e0bbe..a302d47 100644
--- a/p2p/stunprober/stunprober.cc
+++ b/p2p/stunprober/stunprober.cc
@@ -65,7 +65,7 @@
   Requester(StunProber* prober,
             rtc::AsyncPacketSocket* socket,
             const std::vector<rtc::SocketAddress>& server_ips);
-  virtual ~Requester();
+  ~Requester() override;
 
   // There is no callback for SendStunRequest as the underneath socket send is
   // expected to be completed immediately. Otherwise, it'll skip this request
@@ -124,7 +124,7 @@
   if (socket_) {
     socket_->Close();
   }
-  for (auto req : requests_) {
+  for (auto* req : requests_) {
     if (req) {
       delete req;
     }
@@ -220,7 +220,7 @@
 StunProber::Requester::Request* StunProber::Requester::GetRequestByAddress(
     const rtc::IPAddress& ipaddr) {
   RTC_DCHECK(thread_checker_.CalledOnValidThread());
-  for (auto request : requests_) {
+  for (auto* request : requests_) {
     if (request->server_addr == ipaddr) {
       return request;
     }
@@ -229,6 +229,28 @@
   return nullptr;
 }
 
+StunProber::Stats::Stats() = default;
+
+StunProber::Stats::~Stats() = default;
+
+StunProber::ObserverAdapter::ObserverAdapter() = default;
+
+StunProber::ObserverAdapter::~ObserverAdapter() = default;
+
+void StunProber::ObserverAdapter::OnPrepared(StunProber* stunprober,
+                                             Status status) {
+  if (status == SUCCESS) {
+    stunprober->Start(this);
+  } else {
+    callback_(stunprober, status);
+  }
+}
+
+void StunProber::ObserverAdapter::OnFinished(StunProber* stunprober,
+                                             Status status) {
+  callback_(stunprober, status);
+}
+
 StunProber::StunProber(rtc::PacketSocketFactory* socket_factory,
                        rtc::Thread* thread,
                        const rtc::NetworkManager::NetworkList& networks)
@@ -239,12 +261,12 @@
 }
 
 StunProber::~StunProber() {
-  for (auto req : requesters_) {
+  for (auto* req : requesters_) {
     if (req) {
       delete req;
     }
   }
-  for (auto s : sockets_) {
+  for (auto* s : sockets_) {
     if (s) {
       delete s;
     }
@@ -475,7 +497,7 @@
 
   for (auto* requester : requesters_) {
     std::map<rtc::SocketAddress, int> num_response_per_srflx_addr;
-    for (auto request : requester->requests()) {
+    for (auto* request : requester->requests()) {
       if (request->sent_time_ms <= 0) {
         continue;
       }
@@ -539,7 +561,7 @@
       !srflx_addr.FromString(*(stats.srflx_addrs.begin()))) {
     return false;
   }
-  for (const auto& net : networks_) {
+  for (const auto* net : networks_) {
     if (srflx_addr.ipaddr() == net->GetBestIP()) {
       nat_type = stunprober::NATTYPE_NONE;
       stats.host_ip = net->GetBestIP().ToString();
diff --git a/p2p/stunprober/stunprober.h b/p2p/stunprober/stunprober.h
index 4cb0f4d..718e202 100644
--- a/p2p/stunprober/stunprober.h
+++ b/p2p/stunprober/stunprober.h
@@ -69,7 +69,8 @@
   };
 
   struct Stats {
-    Stats() {}
+    Stats();
+    ~Stats();
 
     // |raw_num_request_sent| is the total number of requests
     // sent. |num_request_sent| is the count of requests against a server where
@@ -100,7 +101,7 @@
   StunProber(rtc::PacketSocketFactory* socket_factory,
              rtc::Thread* thread,
              const rtc::NetworkManager::NetworkList& networks);
-  virtual ~StunProber();
+  ~StunProber() override;
 
   // Begin performing the probe test against the |servers|. If
   // |shared_socket_mode| is false, each request will be done with a new socket.
@@ -153,17 +154,12 @@
   // AsyncCallback.
   class ObserverAdapter : public Observer {
    public:
+    ObserverAdapter();
+    ~ObserverAdapter() override;
+
     void set_callback(AsyncCallback callback) { callback_ = callback; }
-    void OnPrepared(StunProber* stunprober, Status status) {
-      if (status == SUCCESS) {
-        stunprober->Start(this);
-      } else {
-        callback_(stunprober, status);
-      }
-    }
-    void OnFinished(StunProber* stunprober, Status status) {
-      callback_(stunprober, status);
-    }
+    void OnPrepared(StunProber* stunprober, Status status) override;
+    void OnFinished(StunProber* stunprober, Status status) override;
 
    private:
     AsyncCallback callback_;