diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2011-01-28 12:53:12 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2011-02-21 10:52:15 (GMT) |
commit | f085092a48966a81315a021367086eb69c02e6a6 (patch) | |
tree | df6cdfc7a161d754323296ee5e7e6926a9d972fc /src/network/access/qnetworkaccesshttpbackend_p.h | |
parent | b8fddce9e6f8dbd30e21cc2d8b20bb1bb0bccba8 (diff) | |
download | Qt-f085092a48966a81315a021367086eb69c02e6a6.zip Qt-f085092a48966a81315a021367086eb69c02e6a6.tar.gz Qt-f085092a48966a81315a021367086eb69c02e6a6.tar.bz2 |
QNAM: Threaded HTTP implementation
HTTP requests are run in a separate thread now.
This required some big changes in the QNetworkAccessHttpBackend.
There is a new class QHttpThreadDelegate which lives in the
HTTP thread and is the communication layer between HTTP code
and QNetworkAccessHttpBackend. Communication is done
via signals/slots.
The synchronous HTTP code (private QtWebKit API) also had to
be completely re-worked and uses its own thread now.
Reviewed-by: Peter Hartmann
Task-number: QTBUG-14162
Diffstat (limited to 'src/network/access/qnetworkaccesshttpbackend_p.h')
-rw-r--r-- | src/network/access/qnetworkaccesshttpbackend_p.h | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h index 7064d4a..712dd2f 100644 --- a/src/network/access/qnetworkaccesshttpbackend_p.h +++ b/src/network/access/qnetworkaccesshttpbackend_p.h @@ -61,6 +61,8 @@ #include "QtCore/qpointer.h" #include "QtCore/qdatetime.h" +#include "QtCore/qsharedpointer.h" +#include "qatomic.h" #ifndef QT_NO_HTTP @@ -99,24 +101,44 @@ public: bool canResume() const; void setResumeOffset(quint64 offset); - virtual bool processRequestSynchronously(); +signals: + // To HTTP thread: + void startHttpRequest(); + void abortHttpRequest(); + void startHttpRequestSynchronously(); + + void haveUploadData(QByteArray dataArray, bool dataAtEnd, qint64 dataSize); private slots: - void replyReadyRead(); + // From HTTP thread: + void replyDownloadData(QByteArray); void replyFinished(); - void replyHeaderChanged(); - void replyDownloadProgressSlot(int,int); + void replyDownloadMetaData(QList<QPair<QByteArray,QByteArray> >,int,QString,bool,QSharedPointer<char>,qint64); + void replyDownloadProgressSlot(qint64,qint64); void httpAuthenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *auth); - void httpCacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *auth); void httpError(QNetworkReply::NetworkError error, const QString &errorString); +#ifndef QT_NO_OPENSSL + void replySslErrors(const QList<QSslError> &, bool *, QList<QSslError> *); + void replySslConfigurationChanged(const QSslConfiguration&); +#endif + + // From QNonContiguousByteDeviceThreadForwardImpl in HTTP thread: + void resetUploadDataSlot(bool *r); + void wantUploadDataSlot(qint64); + void sentUploadDataSlot(qint64); + bool sendCacheContents(const QNetworkCacheMetaData &metaData); - void finished(); // override private: - QHttpNetworkReply *httpReply; - QPointer<QHttpNetworkConnection> http; - QByteArray cacheKey; - QNetworkAccessBackendUploadIODevice *uploadDevice; + QHttpNetworkRequest httpRequest; // There is also a copy in the HTTP thread + int statusCode; + QString reasonPhrase; + // Will be increased by HTTP thread: + QSharedPointer<QAtomicInt> pendingDownloadDataEmissions; + QSharedPointer<QAtomicInt> pendingDownloadProgressEmissions; + bool loadingFromCache; + QByteDataBuffer pendingDownloadData; + bool usingZerocopyDownloadBuffer; #ifndef QT_NO_OPENSSL QSslConfiguration *pendingSslConfiguration; @@ -126,7 +148,6 @@ private: quint64 resumeOffset; - void disconnectFromHttp(); void validateCache(QHttpNetworkRequest &httpRequest, bool &loadedFromCache); void invalidateCache(); void postRequest(); |