mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-11-28 08:16:09 +03:00
73 lines
2.4 KiB
C++
73 lines
2.4 KiB
C++
// 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/tools/quic/quic_simple_client.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "base/logging.h"
|
|
#include "base/run_loop.h"
|
|
#include "base/threading/thread_task_runner_handle.h"
|
|
#include "net/base/net_errors.h"
|
|
#include "net/http/http_request_info.h"
|
|
#include "net/http/http_response_info.h"
|
|
#include "net/log/net_log_source.h"
|
|
#include "net/log/net_log_with_source.h"
|
|
#include "net/quic/chromium/quic_chromium_alarm_factory.h"
|
|
#include "net/quic/chromium/quic_chromium_connection_helper.h"
|
|
#include "net/quic/chromium/quic_chromium_packet_reader.h"
|
|
#include "net/quic/chromium/quic_chromium_packet_writer.h"
|
|
#include "net/quic/core/crypto/quic_random.h"
|
|
#include "net/quic/core/quic_connection.h"
|
|
#include "net/quic/core/quic_packets.h"
|
|
#include "net/quic/core/quic_server_id.h"
|
|
#include "net/quic/core/spdy_utils.h"
|
|
#include "net/quic/platform/api/quic_flags.h"
|
|
#include "net/quic/platform/api/quic_ptr_util.h"
|
|
#include "net/socket/udp_client_socket.h"
|
|
#include "net/spdy/chromium/spdy_http_utils.h"
|
|
#include "net/spdy/core/spdy_header_block.h"
|
|
|
|
using std::string;
|
|
|
|
namespace net {
|
|
|
|
QuicSimpleClient::QuicSimpleClient(
|
|
QuicSocketAddress server_address,
|
|
const QuicServerId& server_id,
|
|
const QuicTransportVersionVector& supported_versions,
|
|
std::unique_ptr<ProofVerifier> proof_verifier)
|
|
: QuicSpdyClientBase(
|
|
server_id,
|
|
supported_versions,
|
|
QuicConfig(),
|
|
CreateQuicConnectionHelper(),
|
|
CreateQuicAlarmFactory(),
|
|
QuicWrapUnique(
|
|
new QuicClientMessageLooplNetworkHelper(&clock_, this)),
|
|
std::move(proof_verifier)),
|
|
initialized_(false),
|
|
weak_factory_(this) {
|
|
set_server_address(server_address);
|
|
}
|
|
|
|
QuicSimpleClient::~QuicSimpleClient() {
|
|
if (connected()) {
|
|
session()->connection()->CloseConnection(
|
|
QUIC_PEER_GOING_AWAY, "Shutting down",
|
|
ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
|
|
}
|
|
}
|
|
|
|
QuicChromiumConnectionHelper* QuicSimpleClient::CreateQuicConnectionHelper() {
|
|
return new QuicChromiumConnectionHelper(&clock_, QuicRandom::GetInstance());
|
|
}
|
|
|
|
QuicChromiumAlarmFactory* QuicSimpleClient::CreateQuicAlarmFactory() {
|
|
return new QuicChromiumAlarmFactory(base::ThreadTaskRunnerHandle::Get().get(),
|
|
&clock_);
|
|
}
|
|
|
|
} // namespace net
|