Move Stopwatch into its own header

Bug: 29748723
Change-Id: I7433f766909177b0ec945aa26f98534069b35891
Test: netd_integration_test
diff --git a/client/NetdClient.cpp b/client/NetdClient.cpp
index 392b0af..91d630d 100644
--- a/client/NetdClient.cpp
+++ b/client/NetdClient.cpp
@@ -26,6 +26,7 @@
 #include "FwmarkClient.h"
 #include "FwmarkCommand.h"
 #include "resolv_netid.h"
+#include "Stopwatch.h"
 
 namespace {
 
diff --git a/include/Stopwatch.h b/include/Stopwatch.h
new file mode 100644
index 0000000..996ecdb
--- /dev/null
+++ b/include/Stopwatch.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NETD_INCLUDE_STOPWATCH_H
+#define NETD_INCLUDE_STOPWATCH_H
+
+#include <chrono>
+
+class Stopwatch {
+public:
+    Stopwatch() : mStart(std::chrono::steady_clock::now()) {}
+    virtual ~Stopwatch() {};
+
+    float timeTaken() const {
+        using ms = std::chrono::duration<float, std::ratio<1, 1000>>;
+        return (std::chrono::duration_cast<ms>(
+                std::chrono::steady_clock::now() - mStart)).count();
+    }
+
+private:
+    std::chrono::time_point<std::chrono::steady_clock> mStart;
+};
+
+#endif  // NETD_INCLUDE_STOPWATCH_H
diff --git a/server/DnsProxyListener.cpp b/server/DnsProxyListener.cpp
index 049fb38..2a5ecc0 100644
--- a/server/DnsProxyListener.cpp
+++ b/server/DnsProxyListener.cpp
@@ -45,6 +45,7 @@
 #include "NetdConstants.h"
 #include "NetworkController.h"
 #include "ResponseCode.h"
+#include "Stopwatch.h"
 #include "android/net/metrics/INetdEventListener.h"
 
 using android::String16;
diff --git a/server/NetdConstants.h b/server/NetdConstants.h
index 605362c..f283ed0 100644
--- a/server/NetdConstants.h
+++ b/server/NetdConstants.h
@@ -60,21 +60,6 @@
 
 const uid_t INVALID_UID = static_cast<uid_t>(-1);
 
-class Stopwatch {
-public:
-    Stopwatch() : mStart(std::chrono::steady_clock::now()) {}
-    virtual ~Stopwatch() {};
-
-    float timeTaken() const {
-        using ms = std::chrono::duration<float, std::ratio<1, 1000>>;
-        return (std::chrono::duration_cast<ms>(
-                std::chrono::steady_clock::now() - mStart)).count();
-    }
-
-private:
-    std::chrono::time_point<std::chrono::steady_clock> mStart;
-};
-
 
 struct AddrinfoDeleter {
     void operator()(struct addrinfo* p) const {
diff --git a/server/SockDiag.cpp b/server/SockDiag.cpp
index f6b8b10..d5150e2 100644
--- a/server/SockDiag.cpp
+++ b/server/SockDiag.cpp
@@ -35,6 +35,7 @@
 #include "NetdConstants.h"
 #include "Permission.h"
 #include "SockDiag.h"
+#include "Stopwatch.h"
 
 #include <chrono>
 
diff --git a/tests/binder_test.cpp b/tests/binder_test.cpp
index 9638230..5f60642 100644
--- a/tests/binder_test.cpp
+++ b/tests/binder_test.cpp
@@ -42,6 +42,7 @@
 #include <netutils/ifc.h>
 
 #include "NetdConstants.h"
+#include "Stopwatch.h"
 #include "android/net/INetd.h"
 #include "android/net/UidRange.h"
 #include "binder/IServiceManager.h"