Refactor Response and Result in DoT code
No functionality change.
Test: mm
Change-Id: I742673798ce597ddff4eecc945201a481e6d356a
diff --git a/DnsTlsQueryMap.h b/DnsTlsQueryMap.h
index a6227f4..a7132a5 100644
--- a/DnsTlsQueryMap.h
+++ b/DnsTlsQueryMap.h
@@ -34,6 +34,8 @@
// All methods are thread-safe and non-blocking.
class DnsTlsQueryMap {
public:
+ enum class Response : uint8_t { success, network_error, limit_error, internal_error };
+
struct Query {
// The new ID number assigned to this query.
uint16_t newId;
@@ -41,8 +43,10 @@
const netdutils::Slice query;
};
- typedef DnsTlsServer::Response Response;
- typedef DnsTlsServer::Result Result;
+ struct Result {
+ Response code;
+ std::vector<uint8_t> response;
+ };
struct QueryFuture {
QueryFuture(Query query, std::future<Result> result)
diff --git a/DnsTlsServer.h b/DnsTlsServer.h
index 82d1a45..8484b98 100644
--- a/DnsTlsServer.h
+++ b/DnsTlsServer.h
@@ -37,13 +37,6 @@
// Allow sockaddr_storage to be promoted to DnsTlsServer automatically.
DnsTlsServer(const sockaddr_storage& ss) : ss(ss) {}
- enum class Response : uint8_t { success, network_error, limit_error, internal_error };
-
- struct Result {
- Response code;
- std::vector<uint8_t> response;
- };
-
// The server location, including IP and port.
sockaddr_storage ss = {};
diff --git a/DnsTlsTransport.h b/DnsTlsTransport.h
index 5f959da..c569fa8 100644
--- a/DnsTlsTransport.h
+++ b/DnsTlsTransport.h
@@ -46,8 +46,8 @@
: mMark(mark), mServer(server), mFactory(factory) {}
~DnsTlsTransport();
- typedef DnsTlsServer::Response Response;
- typedef DnsTlsServer::Result Result;
+ using Response = DnsTlsQueryMap::Response;
+ using Result = DnsTlsQueryMap::Result;
// Given a |query|, this method sends it to the server and returns the result asynchronously.
std::future<Result> query(const netdutils::Slice query) EXCLUDES(mLock);
diff --git a/resolv_tls_unit_test.cpp b/resolv_tls_unit_test.cpp
index ed9c218..1fbf5ae 100644
--- a/resolv_tls_unit_test.cpp
+++ b/resolv_tls_unit_test.cpp
@@ -180,9 +180,9 @@
DnsTlsTransport transport(SERVER1, MARK, &factory);
for (int i = 0; i < 100; ++i) {
// Send a query.
- std::future<DnsTlsServer::Result> f = transport.query(makeSlice(QUERY));
+ std::future<DnsTlsTransport::Result> f = transport.query(makeSlice(QUERY));
// Wait for the response.
- DnsTlsServer::Result r = f.get();
+ DnsTlsTransport::Result r = f.get();
EXPECT_EQ(DnsTlsTransport::Response::success, r.code);
// All queries should have an observed ID of zero, because it is returned to the ID pool