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 | #include "net/third_party/quiche/src/quic/tools/quic_client.h" |
| 6 | |
| 7 | #include <errno.h> |
| 8 | #include <netinet/in.h> |
| 9 | #include <string.h> |
| 10 | #include <sys/epoll.h> |
| 11 | #include <sys/socket.h> |
| 12 | |
| 13 | #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" |
| 14 | #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" |
| 15 | #include "net/third_party/quiche/src/quic/core/quic_connection.h" |
| 16 | #include "net/third_party/quiche/src/quic/core/quic_data_reader.h" |
| 17 | #include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" |
| 18 | #include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" |
| 19 | #include "net/third_party/quiche/src/quic/core/quic_packets.h" |
| 20 | #include "net/third_party/quiche/src/quic/core/quic_server_id.h" |
| 21 | #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" |
| 22 | #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" |
| 23 | #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" |
| 24 | #include "net/quic/platform/impl/quic_socket_utils.h" |
| 25 | #include "net/third_party/quiche/src/quic/tools/quic_simple_client_session.h" |
| 26 | |
| 27 | #ifndef SO_RXQ_OVFL |
| 28 | #define SO_RXQ_OVFL 40 |
| 29 | #endif |
| 30 | |
| 31 | namespace quic { |
| 32 | |
| 33 | QuicClient::QuicClient(QuicSocketAddress server_address, |
| 34 | const QuicServerId& server_id, |
| 35 | const ParsedQuicVersionVector& supported_versions, |
| 36 | QuicEpollServer* epoll_server, |
| 37 | std::unique_ptr<ProofVerifier> proof_verifier) |
| 38 | : QuicClient( |
| 39 | server_address, |
| 40 | server_id, |
| 41 | supported_versions, |
| 42 | QuicConfig(), |
| 43 | epoll_server, |
| 44 | QuicWrapUnique(new QuicClientEpollNetworkHelper(epoll_server, this)), |
| 45 | std::move(proof_verifier)) {} |
| 46 | |
| 47 | QuicClient::QuicClient( |
| 48 | QuicSocketAddress server_address, |
| 49 | const QuicServerId& server_id, |
| 50 | const ParsedQuicVersionVector& supported_versions, |
| 51 | QuicEpollServer* epoll_server, |
| 52 | std::unique_ptr<QuicClientEpollNetworkHelper> network_helper, |
| 53 | std::unique_ptr<ProofVerifier> proof_verifier) |
| 54 | : QuicClient(server_address, |
| 55 | server_id, |
| 56 | supported_versions, |
| 57 | QuicConfig(), |
| 58 | epoll_server, |
| 59 | std::move(network_helper), |
| 60 | std::move(proof_verifier)) {} |
| 61 | |
| 62 | QuicClient::QuicClient( |
| 63 | QuicSocketAddress server_address, |
| 64 | const QuicServerId& server_id, |
| 65 | const ParsedQuicVersionVector& supported_versions, |
| 66 | const QuicConfig& config, |
| 67 | QuicEpollServer* epoll_server, |
| 68 | std::unique_ptr<QuicClientEpollNetworkHelper> network_helper, |
| 69 | std::unique_ptr<ProofVerifier> proof_verifier) |
| 70 | : QuicSpdyClientBase( |
| 71 | server_id, |
| 72 | supported_versions, |
| 73 | config, |
| 74 | new QuicEpollConnectionHelper(epoll_server, QuicAllocator::SIMPLE), |
| 75 | new QuicEpollAlarmFactory(epoll_server), |
| 76 | std::move(network_helper), |
| 77 | std::move(proof_verifier)) { |
| 78 | set_server_address(server_address); |
| 79 | } |
| 80 | |
| 81 | QuicClient::~QuicClient() = default; |
| 82 | |
| 83 | std::unique_ptr<QuicSession> QuicClient::CreateQuicClientSession( |
| 84 | const ParsedQuicVersionVector& supported_versions, |
| 85 | QuicConnection* connection) { |
| 86 | return QuicMakeUnique<QuicSimpleClientSession>( |
| 87 | *config(), supported_versions, connection, server_id(), crypto_config(), |
| 88 | push_promise_index(), drop_response_body_); |
| 89 | } |
| 90 | |
| 91 | QuicClientEpollNetworkHelper* QuicClient::epoll_network_helper() { |
| 92 | return static_cast<QuicClientEpollNetworkHelper*>(network_helper()); |
| 93 | } |
| 94 | |
| 95 | const QuicClientEpollNetworkHelper* QuicClient::epoll_network_helper() const { |
| 96 | return static_cast<const QuicClientEpollNetworkHelper*>(network_helper()); |
| 97 | } |
| 98 | |
| 99 | } // namespace quic |