1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// Copyright (c) 2019 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/qbone/qbone_client.h"
#include <utility>
#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/platform/api/quic_epoll.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h"
#include "net/third_party/quiche/src/quic/qbone/qbone_stream.h"
namespace quic {
namespace {
std::unique_ptr<QuicClientBase::NetworkHelper> CreateNetworkHelper(
QuicEpollServer* epoll_server,
QboneClient* client) {
std::unique_ptr<QuicClientBase::NetworkHelper> helper =
std::make_unique<QuicClientEpollNetworkHelper>(epoll_server, client);
testing::testvalue::Adjust("QboneClient/network_helper", &helper);
return helper;
}
} // namespace
QboneClient::QboneClient(QuicSocketAddress server_address,
const QuicServerId& server_id,
const ParsedQuicVersionVector& supported_versions,
QuicSession::Visitor* session_owner,
const QuicConfig& config,
QuicEpollServer* epoll_server,
std::unique_ptr<ProofVerifier> proof_verifier,
QbonePacketWriter* qbone_writer,
QboneClientControlStream::Handler* qbone_handler)
: QuicClientBase(
server_id,
supported_versions,
config,
new QuicEpollConnectionHelper(epoll_server, QuicAllocator::SIMPLE),
new QuicEpollAlarmFactory(epoll_server),
CreateNetworkHelper(epoll_server, this),
std::move(proof_verifier)),
qbone_writer_(qbone_writer),
qbone_handler_(qbone_handler),
session_owner_(session_owner) {
set_server_address(server_address);
crypto_config()->set_alpn("qbone");
}
QboneClient::~QboneClient() {
ResetSession();
}
QboneClientSession* QboneClient::qbone_session() {
return static_cast<QboneClientSession*>(QuicClientBase::session());
}
void QboneClient::ProcessPacketFromNetwork(QuicStringPiece packet) {
qbone_session()->ProcessPacketFromNetwork(packet);
}
int QboneClient::GetNumSentClientHellosFromSession() {
return qbone_session()->GetNumSentClientHellos();
}
int QboneClient::GetNumReceivedServerConfigUpdatesFromSession() {
return qbone_session()->GetNumReceivedServerConfigUpdates();
}
void QboneClient::ResendSavedData() {
// no op.
}
void QboneClient::ClearDataToResend() {
// no op.
}
bool QboneClient::HasActiveRequests() {
return qbone_session()->HasActiveRequests();
}
class QboneClientSessionWithConnection : public QboneClientSession {
public:
using QboneClientSession::QboneClientSession;
~QboneClientSessionWithConnection() override { delete connection(); }
};
// Takes ownership of |connection|.
std::unique_ptr<QuicSession> QboneClient::CreateQuicClientSession(
const ParsedQuicVersionVector& supported_versions,
QuicConnection* connection) {
return std::make_unique<QboneClientSessionWithConnection>(
connection, crypto_config(), session_owner(), *config(),
supported_versions, server_id(), qbone_writer_, qbone_handler_);
}
} // namespace quic
|