diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2020-05-13 12:14:21 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2020-05-15 15:44:22 +0200 |
commit | bd3b978701c32b2e13da853f2064aab369e32745 (patch) | |
tree | 722a184b72e5ab6e2f7f6c8862311759ad737a33 | |
parent | 035c16e9ff6cdc169dc6cf8ce94fc5c9e3769f7f (diff) |
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>
-rw-r--r-- | src/network/access/qnetworkreply_p.h | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyhttpimpl.cpp | 52 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyhttpimpl_p.h | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl.cpp | 57 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl_p.h | 3 |
5 files changed, 3 insertions, 113 deletions
diff --git a/src/network/access/qnetworkreply_p.h b/src/network/access/qnetworkreply_p.h index 66d8c9d527..3b3bb3dfa4 100644 --- a/src/network/access/qnetworkreply_p.h +++ b/src/network/access/qnetworkreply_p.h @@ -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(); diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index d02b209d51..a6688bfd7a 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -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 diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h index eef4b13d12..a25adb668c 100644 --- a/src/network/access/qnetworkreplyhttpimpl_p.h +++ b/src/network/access/qnetworkreplyhttpimpl_p.h @@ -229,11 +229,9 @@ public: #endif - bool migrateBackend(); bool canResume() const; void setResumeOffset(quint64 offset); quint64 resumeOffset; - qint64 preMigrationDownloaded; qint64 bytesDownloaded; qint64 bytesBuffered; diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index b0674823f7..b0f8fa1c7d 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -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) diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 6a100d9a03..d5b67d4c9c 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -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; |