Code cleanup in QNAM
The private class already store a QNetworkConfigurationManager and networkSessionRequired so it's not need to compute them again nor to instantiate temporary classes. Change-Id: I1bbd9439afa70c950ed6ec3e4fc63ddae4a5b259 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
0f3c9782e6
commit
048c380629
@ -985,8 +985,7 @@ QNetworkConfiguration QNetworkAccessManager::configuration() const
|
||||
if (session) {
|
||||
return session->configuration();
|
||||
} else {
|
||||
QNetworkConfigurationManager manager;
|
||||
return manager.defaultConfiguration();
|
||||
return d->networkConfigurationManager.defaultConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1010,12 +1009,11 @@ QNetworkConfiguration QNetworkAccessManager::activeConfiguration() const
|
||||
Q_D(const QNetworkAccessManager);
|
||||
|
||||
QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession());
|
||||
QNetworkConfigurationManager manager;
|
||||
if (networkSession) {
|
||||
return manager.configurationFromIdentifier(
|
||||
return d->networkConfigurationManager.configurationFromIdentifier(
|
||||
networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString());
|
||||
} else {
|
||||
return manager.defaultConfiguration();
|
||||
return d->networkConfigurationManager.defaultConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1342,17 +1340,16 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
|
||||
}
|
||||
|
||||
if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) {
|
||||
QNetworkConfigurationManager manager;
|
||||
if (!d->networkConfiguration.identifier().isEmpty()) {
|
||||
if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined)
|
||||
&& d->networkConfiguration != manager.defaultConfiguration())
|
||||
d->createSession(manager.defaultConfiguration());
|
||||
&& d->networkConfiguration != d->networkConfigurationManager.defaultConfiguration())
|
||||
d->createSession(d->networkConfigurationManager.defaultConfiguration());
|
||||
else
|
||||
d->createSession(d->networkConfiguration);
|
||||
|
||||
} else {
|
||||
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
|
||||
d->createSession(manager.defaultConfiguration());
|
||||
if (d->networkSessionRequired)
|
||||
d->createSession(d->networkConfigurationManager.defaultConfiguration());
|
||||
else
|
||||
d->initializeSession = false;
|
||||
}
|
||||
@ -1884,8 +1881,8 @@ void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline)
|
||||
online = (networkConfiguration.state() & QNetworkConfiguration::Active);
|
||||
} else {
|
||||
if (online != isOnline) {
|
||||
_q_networkSessionClosed();
|
||||
createSession(q->configuration());
|
||||
_q_networkSessionClosed();
|
||||
createSession(q->configuration());
|
||||
online = isOnline;
|
||||
}
|
||||
}
|
||||
@ -1909,13 +1906,13 @@ void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfigu
|
||||
const QString id = configuration.identifier();
|
||||
if (configuration.state().testFlag(QNetworkConfiguration::Active)) {
|
||||
if (!onlineConfigurations.contains(id)) {
|
||||
|
||||
QSharedPointer<QNetworkSession> session(getNetworkSession());
|
||||
if (session) {
|
||||
if (online && session->configuration().identifier()
|
||||
!= networkConfigurationManager.defaultConfiguration().identifier()) {
|
||||
|
||||
onlineConfigurations.insert(id);
|
||||
// CHECK: If it's having Active flag - why would it be disconnected ???
|
||||
//this one disconnected but another one is online,
|
||||
// close and create new session
|
||||
_q_networkSessionClosed();
|
||||
@ -1926,6 +1923,7 @@ void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfigu
|
||||
|
||||
} else if (onlineConfigurations.contains(id)) {
|
||||
//this one is disconnecting
|
||||
// CHECK: If it disconnected while we create a session over a down configuration ???
|
||||
onlineConfigurations.remove(id);
|
||||
if (!onlineConfigurations.isEmpty()) {
|
||||
_q_networkSessionClosed();
|
||||
|
Loading…
Reference in New Issue
Block a user