QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // 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 team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 15 | #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 team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 19 | #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 | |
| 24 | namespace quic { |
| 25 | |
| 26 | class QuicServerId; |
| 27 | |
| 28 | namespace test { |
| 29 | class QuicClientPeer; |
| 30 | } // namespace test |
| 31 | |
nharper | 2eb3f38 | 2019-07-24 14:12:31 -0700 | [diff] [blame] | 32 | namespace tools { |
| 33 | |
| 34 | QuicSocketAddress LookupAddress(std::string host, std::string port); |
| 35 | |
| 36 | } // namespace tools |
| 37 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 38 | class QuicClient : public QuicSpdyClientBase { |
| 39 | public: |
nharper | 41ac9df | 2019-11-11 15:09:23 -0800 | [diff] [blame] | 40 | // These will create their own QuicClientEpollNetworkHelper. |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 41 | 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); |
nharper | 41ac9df | 2019-11-11 15:09:23 -0800 | [diff] [blame] | 46 | 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 team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 52 | // 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); |
nharper | 41ac9df | 2019-11-11 15:09:23 -0800 | [diff] [blame] | 66 | 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 team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 74 | 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 team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 89 | private: |
| 90 | friend class test::QuicClientPeer; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // namespace quic |
| 94 | |
| 95 | #endif // QUICHE_QUIC_TOOLS_QUIC_CLIENT_H_ |