OSDN Git Service

DO NOT MERGE Move Stopwatch into its own header
authorRobin Lee <rgl@google.com>
Wed, 21 Sep 2016 07:31:33 +0000 (16:31 +0900)
committerMichal Karpinski <mkarpinski@google.com>
Fri, 2 Dec 2016 13:42:04 +0000 (13:42 +0000)
Bug: 29748723
Test: netd_integration_test

(cherry picked from commit cc544162e08dd0df271cd77a3f2c85dbaaa461e2)

Change-Id: Icc2f633206b9f8052ca9ae2b775984b4f4be97b9

client/NetdClient.cpp
include/Stopwatch.h [new file with mode: 0644]
server/DnsProxyListener.cpp
server/NetdConstants.h
server/SockDiag.cpp
tests/binder_test.cpp

index 392b0af..91d630d 100644 (file)
@@ -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 (file)
index 0000000..996ecdb
--- /dev/null
@@ -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
index 049fb38..2a5ecc0 100644 (file)
@@ -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;
index 605362c..f283ed0 100644 (file)
@@ -60,21 +60,6 @@ int parsePrefix(const char *prefix, uint8_t *family, void *address, int size, ui
 
 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 {
index 1517b94..11711af 100644 (file)
@@ -35,6 +35,7 @@
 #include "NetdConstants.h"
 #include "Permission.h"
 #include "SockDiag.h"
+#include "Stopwatch.h"
 
 #include <chrono>
 
index fd94d2e..5395f1d 100644 (file)
@@ -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"