blob: 770590796e140ad0c720487bc98242d23ada911c [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/third_party/quiche/src/quic/tools/quic_client.h"
#include <errno.h>
#include <features.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <iostream>
#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h"
#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h"
#include "net/third_party/quiche/src/quic/core/quic_connection.h"
#include "net/third_party/quiche/src/quic/core/quic_data_reader.h"
#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h"
#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h"
#include "net/third_party/quiche/src/quic/core/quic_packets.h"
#include "net/third_party/quiche/src/quic/core/quic_server_id.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h"
#include "net/quic/platform/impl/quic_socket_utils.h"
#include "net/third_party/quiche/src/quic/tools/quic_simple_client_session.h"
#ifndef SO_RXQ_OVFL
#define SO_RXQ_OVFL 40
#endif
namespace quic {
QuicClient::QuicClient(QuicSocketAddress server_address,
const QuicServerId& server_id,
const ParsedQuicVersionVector& supported_versions,
QuicEpollServer* epoll_server,
std::unique_ptr<ProofVerifier> proof_verifier)
: QuicClient(
server_address,
server_id,
supported_versions,
QuicConfig(),
epoll_server,
QuicWrapUnique(new QuicClientEpollNetworkHelper(epoll_server, this)),
std::move(proof_verifier)) {}
QuicClient::QuicClient(
QuicSocketAddress server_address,
const QuicServerId& server_id,
const ParsedQuicVersionVector& supported_versions,
QuicEpollServer* epoll_server,
std::unique_ptr<QuicClientEpollNetworkHelper> network_helper,
std::unique_ptr<ProofVerifier> proof_verifier)
: QuicClient(server_address,
server_id,
supported_versions,
QuicConfig(),
epoll_server,
std::move(network_helper),
std::move(proof_verifier)) {}
QuicClient::QuicClient(
QuicSocketAddress server_address,
const QuicServerId& server_id,
const ParsedQuicVersionVector& supported_versions,
const QuicConfig& config,
QuicEpollServer* epoll_server,
std::unique_ptr<QuicClientEpollNetworkHelper> network_helper,
std::unique_ptr<ProofVerifier> proof_verifier)
: QuicSpdyClientBase(
server_id,
supported_versions,
config,
new QuicEpollConnectionHelper(epoll_server, QuicAllocator::SIMPLE),
new QuicEpollAlarmFactory(epoll_server),
std::move(network_helper),
std::move(proof_verifier)) {
set_server_address(server_address);
}
QuicClient::~QuicClient() = default;
std::unique_ptr<QuicSession> QuicClient::CreateQuicClientSession(
const ParsedQuicVersionVector& supported_versions,
QuicConnection* connection) {
return QuicMakeUnique<QuicSimpleClientSession>(
*config(), supported_versions, connection, server_id(), crypto_config(),
push_promise_index(), drop_response_body_);
}
QuicClientEpollNetworkHelper* QuicClient::epoll_network_helper() {
return down_cast<QuicClientEpollNetworkHelper*>(network_helper());
}
const QuicClientEpollNetworkHelper* QuicClient::epoll_network_helper() const {
return down_cast<const QuicClientEpollNetworkHelper*>(network_helper());
}
} // namespace quic