blob: 9c597a0101c6e89bb7c96d87cefc16d9c374918d [file] [log] [blame]
Ben Schwartzded1b702017-10-25 14:41:02 -04001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _DNS_DNSTLSSOCKETFACTORY_H
18#define _DNS_DNSTLSSOCKETFACTORY_H
19
20#include <memory>
21
22#include "dns/DnsTlsSocket.h"
23#include "dns/IDnsTlsSocketFactory.h"
24
25namespace android {
26namespace net {
27
28class DnsTlsSessionCache;
29struct DnsTlsServer;
30
31// Trivial RAII factory for DnsTlsSocket. This is owned by DnsTlsDispatcher.
32class DnsTlsSocketFactory : public IDnsTlsSocketFactory {
33public:
34 std::unique_ptr<IDnsTlsSocket> createDnsTlsSocket(const DnsTlsServer& server, unsigned mark,
35 DnsTlsSessionCache* _Nonnull cache) override {
36 auto socket = std::make_unique<DnsTlsSocket>(server, mark, cache);
37 if (!socket->initialize()) {
38 return nullptr;
39 }
40 return std::move(socket);
41 }
42};
43
44} // end of namespace net
45} // end of namespace android
46
47#endif // _DNS_DNSTLSSOCKETFACTORY_H