QHttpNetworkConnectionPrivate: move some init logic into a function

Now we can nicely initialize it as a member-initializer.
Do channels at the same time, NSDMI follows.

Task-number: QTBUG-102855
Change-Id: I59c1fe044687500ed3a9d5878c6e4fc137114542
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
Mårten Nordheim 2024-03-21 15:56:19 +01:00
parent e88a2ed83b
commit 28bff27b85
1 changed files with 10 additions and 6 deletions

View File

@ -40,24 +40,28 @@ const int QHttpNetworkConnectionPrivate::defaultPipelineLength = 3;
// This means that there are 2 requests in flight and 2 slots free that will be re-filled.
const int QHttpNetworkConnectionPrivate::defaultRePipelineLength = 2;
static int getPreferredActiveChannelCount(QHttpNetworkConnection::ConnectionType type,
int defaultValue)
{
return (type == QHttpNetworkConnection::ConnectionTypeHTTP2
|| type == QHttpNetworkConnection::ConnectionTypeHTTP2Direct)
? 1
: defaultValue;
}
QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 connectionCount, const QString &hostName,
quint16 port, bool encrypt,
QHttpNetworkConnection::ConnectionType type)
: state(RunningState), networkLayerState(Unknown),
hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true),
channelCount(connectionCount)
activeChannelCount(getPreferredActiveChannelCount(type, connectionCount)),
channelCount(connectionCount), channels(new QHttpNetworkConnectionChannel[channelCount])
#ifndef QT_NO_NETWORKPROXY
, networkProxy(QNetworkProxy::NoProxy)
#endif
, preConnectRequests(0)
, connectionType(type)
{
channels = new QHttpNetworkConnectionChannel[channelCount];
activeChannelCount = (type == QHttpNetworkConnection::ConnectionTypeHTTP2 ||
type == QHttpNetworkConnection::ConnectionTypeHTTP2Direct)
? 1 : connectionCount;
// We allocate all 6 channels even if it's an HTTP/2-enabled
// connection: in case the protocol negotiation via NPN/ALPN fails,
// we will have normally working HTTP/1.1.