QNetworkReply: Remove some bearer management leftovers

migrating backend was done if the QNetworkSession changed. With
QNetworkSession gone this was no longer called from anywhere.

Change-Id: I8c995001f9d4c7ae83446b4d29fa62c954c79889
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Mårten Nordheim 2020-05-13 12:14:21 +02:00
parent 035c16e9ff
commit bd3b978701
5 changed files with 3 additions and 113 deletions

View File

@ -70,8 +70,6 @@ public:
Working, // The reply is uploading/downloading data.
Finished, // The reply has finished.
Aborted, // The reply has been aborted.
WaitingForSession, // The reply is waiting for the session to open before connecting.
Reconnecting // The reply will reconnect to once roaming has completed.
};
QNetworkReplyPrivate();

View File

@ -281,10 +281,6 @@ void QNetworkReplyHttpImpl::abort()
// call finished which will emit signals
// FIXME shouldn't this be emitted Queued?
d->error(OperationCanceledError, tr("Operation canceled"));
// If state is WaitingForSession, calling finished has no effect
if (d->state == QNetworkReplyPrivate::WaitingForSession)
d->state = QNetworkReplyPrivate::Working;
d->finished();
}
@ -443,7 +439,6 @@ QNetworkReplyHttpImplPrivate::QNetworkReplyHttpImplPrivate()
, cacheSaveDevice(nullptr)
, cacheEnabled(false)
, resumeOffset(0)
, preMigrationDownloaded(-1)
, bytesDownloaded(0)
, bytesBuffered(0)
, transferTimeout(nullptr)
@ -1063,8 +1058,6 @@ void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d)
return;
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
if (preMigrationDownloaded != Q_INT64_C(-1))
totalSize = totalSize.toLongLong() + preMigrationDownloaded;
emit q->readyRead();
// emit readyRead before downloadProgress incase this will cause events to be
@ -1983,12 +1976,10 @@ void QNetworkReplyHttpImplPrivate::finished()
Q_Q(QNetworkReplyHttpImpl);
if (transferTimeout)
transferTimeout->stop();
if (state == Finished || state == Aborted || state == WaitingForSession)
if (state == Finished || state == Aborted)
return;
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
if (preMigrationDownloaded != Q_INT64_C(-1))
totalSize = totalSize.toLongLong() + preMigrationDownloaded;
// if we don't know the total size of or we received everything save the cache
if (totalSize.isNull() || totalSize == -1 || bytesDownloaded == totalSize)
@ -2061,47 +2052,6 @@ void QNetworkReplyHttpImplPrivate::_q_metaDataChanged()
emit q->metaDataChanged();
}
/*
Migrates the backend of the QNetworkReply to a new network connection if required. Returns
true if the reply is migrated or it is not required; otherwise returns \c false.
*/
bool QNetworkReplyHttpImplPrivate::migrateBackend()
{
Q_Q(QNetworkReplyHttpImpl);
// Network reply is already finished or aborted, don't need to migrate.
if (state == Finished || state == Aborted)
return true;
// Backend does not support resuming download.
if (!canResume())
return false;
// Request has outgoing data, not migrating.
if (outgoingData)
return false;
// Request is serviced from the cache, don't need to migrate.
if (cacheLoadDevice)
return true;
state = Reconnecting;
cookedHeaders.clear();
rawHeaders.clear();
preMigrationDownloaded = bytesDownloaded;
setResumeOffset(bytesDownloaded);
emit q->abortHttpRequest();
QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
return true;
}
void QNetworkReplyHttpImplPrivate::createCache()
{
// check if we can save and if we're allowed to

View File

@ -229,11 +229,9 @@ public:
#endif
bool migrateBackend();
bool canResume() const;
void setResumeOffset(quint64 offset);
quint64 resumeOffset;
qint64 preMigrationDownloaded;
qint64 bytesDownloaded;
qint64 bytesBuffered;

View File

@ -56,7 +56,7 @@ inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate()
copyDevice(nullptr),
cacheEnabled(false), cacheSaveDevice(nullptr),
notificationHandlingPaused(false),
bytesDownloaded(0), lastBytesDownloaded(-1), bytesUploaded(-1), preMigrationDownloaded(-1),
bytesDownloaded(0), lastBytesDownloaded(-1), bytesUploaded(-1),
httpStatusCode(0),
state(Idle)
, downloadBufferReadPosition(0)
@ -157,8 +157,6 @@ void QNetworkReplyImplPrivate::_q_copyReadyRead()
lastBytesDownloaded = bytesDownloaded;
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
if (preMigrationDownloaded != Q_INT64_C(-1))
totalSize = totalSize.toLongLong() + preMigrationDownloaded;
pauseNotificationHandling();
// emit readyRead before downloadProgress incase this will cause events to be
// processed and we get into a recursive call (as in QProgressDialog).
@ -525,8 +523,6 @@ void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions()
Q_Q(QNetworkReplyImpl);
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
if (preMigrationDownloaded != Q_INT64_C(-1))
totalSize = totalSize.toLongLong() + preMigrationDownloaded;
pauseNotificationHandling();
// important: At the point of this readyRead(), the data parameter list must be empty,
// else implicit sharing will trigger memcpy when the user is reading data!
@ -653,13 +649,11 @@ void QNetworkReplyImplPrivate::finished()
{
Q_Q(QNetworkReplyImpl);
if (state == Finished || state == Aborted || state == WaitingForSession)
if (state == Finished || state == Aborted)
return;
pauseNotificationHandling();
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
if (preMigrationDownloaded != Q_INT64_C(-1))
totalSize = totalSize.toLongLong() + preMigrationDownloaded;
resumeNotificationHandling();
@ -787,8 +781,6 @@ void QNetworkReplyImpl::abort()
// call finished which will emit signals
d->error(OperationCanceledError, tr("Operation canceled"));
if (d->state == QNetworkReplyPrivate::WaitingForSession)
d->state = QNetworkReplyPrivate::Working;
d->finished();
d->state = QNetworkReplyPrivate::Aborted;
@ -919,51 +911,6 @@ bool QNetworkReplyImpl::event(QEvent *e)
return QObject::event(e);
}
/*
Migrates the backend of the QNetworkReply to a new network connection if required. Returns
true if the reply is migrated or it is not required; otherwise returns \c false.
*/
bool QNetworkReplyImplPrivate::migrateBackend()
{
Q_Q(QNetworkReplyImpl);
// Network reply is already finished or aborted, don't need to migrate.
if (state == Finished || state == Aborted)
return true;
// Request has outgoing data, not migrating.
if (outgoingData)
return false;
// Request is serviced from the cache, don't need to migrate.
if (copyDevice)
return true;
// Backend does not support resuming download.
if (backend && !backend->canResume())
return false;
state = QNetworkReplyPrivate::Reconnecting;
cookedHeaders.clear();
rawHeaders.clear();
preMigrationDownloaded = bytesDownloaded;
delete backend;
backend = manager->d_func()->findBackend(operation, request);
if (backend) {
backend->setParent(q);
backend->reply = this;
backend->setResumeOffset(bytesDownloaded);
}
QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
return true;
}
QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent,
const QNetworkRequest &req,
QNetworkAccessManager::Operation op)

View File

@ -158,8 +158,6 @@ public:
QIODevice *copyDevice;
QAbstractNetworkCache *networkCache() const;
bool migrateBackend();
bool cacheEnabled;
QIODevice *cacheSaveDevice;
@ -175,7 +173,6 @@ public:
qint64 bytesDownloaded;
qint64 lastBytesDownloaded;
qint64 bytesUploaded;
qint64 preMigrationDownloaded;
QString httpReasonPhrase;
int httpStatusCode;