blob: 10c61f378d0ac4116267d3d626df5ea02fe5ceab [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// A toy client, which connects to a specified port and sends QUIC
6// request to that endpoint.
7
8#ifndef QUICHE_QUIC_TOOLS_QUIC_CLIENT_H_
9#define QUICHE_QUIC_TOOLS_QUIC_CLIENT_H_
10
11#include <cstdint>
12#include <memory>
13#include <string>
14
QUICHE teama6ef0a62019-03-07 20:34:33 -050015#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h"
16#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h"
17#include "net/third_party/quiche/src/quic/core/quic_config.h"
18#include "net/third_party/quiche/src/quic/core/quic_packet_reader.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050019#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h"
20#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h"
21#include "net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.h"
22#include "net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h"
23
24namespace quic {
25
26class QuicServerId;
27
28namespace test {
29class QuicClientPeer;
30} // namespace test
31
nharper2eb3f382019-07-24 14:12:31 -070032namespace tools {
33
34QuicSocketAddress LookupAddress(std::string host, std::string port);
35
36} // namespace tools
37
QUICHE teama6ef0a62019-03-07 20:34:33 -050038class QuicClient : public QuicSpdyClientBase {
39 public:
nharper41ac9df2019-11-11 15:09:23 -080040 // These will create their own QuicClientEpollNetworkHelper.
QUICHE teama6ef0a62019-03-07 20:34:33 -050041 QuicClient(QuicSocketAddress server_address,
42 const QuicServerId& server_id,
43 const ParsedQuicVersionVector& supported_versions,
44 QuicEpollServer* epoll_server,
45 std::unique_ptr<ProofVerifier> proof_verifier);
nharper41ac9df2019-11-11 15:09:23 -080046 QuicClient(QuicSocketAddress server_address,
47 const QuicServerId& server_id,
48 const ParsedQuicVersionVector& supported_versions,
49 QuicEpollServer* epoll_server,
50 std::unique_ptr<ProofVerifier> proof_verifier,
51 std::unique_ptr<SessionCache> session_cache);
QUICHE teama6ef0a62019-03-07 20:34:33 -050052 // This will take ownership of a passed in network primitive.
53 QuicClient(QuicSocketAddress server_address,
54 const QuicServerId& server_id,
55 const ParsedQuicVersionVector& supported_versions,
56 QuicEpollServer* epoll_server,
57 std::unique_ptr<QuicClientEpollNetworkHelper> network_helper,
58 std::unique_ptr<ProofVerifier> proof_verifier);
59 QuicClient(QuicSocketAddress server_address,
60 const QuicServerId& server_id,
61 const ParsedQuicVersionVector& supported_versions,
62 const QuicConfig& config,
63 QuicEpollServer* epoll_server,
64 std::unique_ptr<QuicClientEpollNetworkHelper> network_helper,
65 std::unique_ptr<ProofVerifier> proof_verifier);
nharper41ac9df2019-11-11 15:09:23 -080066 QuicClient(QuicSocketAddress server_address,
67 const QuicServerId& server_id,
68 const ParsedQuicVersionVector& supported_versions,
69 const QuicConfig& config,
70 QuicEpollServer* epoll_server,
71 std::unique_ptr<QuicClientEpollNetworkHelper> network_helper,
72 std::unique_ptr<ProofVerifier> proof_verifier,
73 std::unique_ptr<SessionCache> session_cache);
QUICHE teama6ef0a62019-03-07 20:34:33 -050074 QuicClient(const QuicClient&) = delete;
75 QuicClient& operator=(const QuicClient&) = delete;
76
77 ~QuicClient() override;
78
79 std::unique_ptr<QuicSession> CreateQuicClientSession(
80 const ParsedQuicVersionVector& supported_versions,
81 QuicConnection* connection) override;
82
83 // Exposed for the quic client test.
84 int GetLatestFD() const { return epoll_network_helper()->GetLatestFD(); }
85
86 QuicClientEpollNetworkHelper* epoll_network_helper();
87 const QuicClientEpollNetworkHelper* epoll_network_helper() const;
88
QUICHE teama6ef0a62019-03-07 20:34:33 -050089 private:
90 friend class test::QuicClientPeer;
QUICHE teama6ef0a62019-03-07 20:34:33 -050091};
92
93} // namespace quic
94
95#endif // QUICHE_QUIC_TOOLS_QUIC_CLIENT_H_