summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkaccessbackend.cpp
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2009-05-13 11:16:04 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2009-05-13 11:42:04 (GMT)
commit21199a2bb0b5d6c4d419157656c975c16c947b8f (patch)
tree6cca7a93433850b5c814ce4612eabd81538bc38a /src/network/access/qnetworkaccessbackend.cpp
parent9d827648b7618cd3bdad6548e83b1d16453c96bf (diff)
downloadQt-21199a2bb0b5d6c4d419157656c975c16c947b8f.zip
Qt-21199a2bb0b5d6c4d419157656c975c16c947b8f.tar.gz
Qt-21199a2bb0b5d6c4d419157656c975c16c947b8f.tar.bz2
QNAM: Upload architecture change: Backend and QNetworkReplyImpl changes
Reviewed-by: Thiago Macieira Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network/access/qnetworkaccessbackend.cpp')
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp57
1 files changed, 34 insertions, 23 deletions
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp
index df468b8..b9d1b85 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -50,6 +50,8 @@
#include "qnetworkaccesscachebackend_p.h"
#include "qabstractnetworkcache.h"
+#include "private/qnoncontiguousbytedevice_p.h"
+
QT_BEGIN_NAMESPACE
static bool factoryDataShutdown = false;
@@ -109,17 +111,43 @@ QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessM
return 0;
}
-QNetworkAccessBackend::QNetworkAccessBackend()
+
+QNonContiguousByteDevice* QNetworkAccessBackend::createUploadByteDevice()
{
+ QNonContiguousByteDevice* device = 0;
+
+ if (reply->outgoingDataBuffer)
+ device = QNonContiguousByteDeviceFactory::create(reply->outgoingDataBuffer);
+ else
+ device = QNonContiguousByteDeviceFactory::create(reply->outgoingData);
+
+ bool bufferDisallowed =
+ reply->request.attribute(QNetworkRequest::DoNotBufferUploadDataAttribute,
+ QVariant(false)) == QVariant(true);
+ if (bufferDisallowed)
+ device->disableReset();
+
+ // make sure we delete this later
+ device->setParent(this);
+
+ connect(device, SIGNAL(readProgress(qint64,qint64)), this, SLOT(emitReplyUploadProgress(qint64,qint64)));
+
+ return device;
}
-QNetworkAccessBackend::~QNetworkAccessBackend()
+// need to have this function since the reply is a private member variable
+// and the special backends need to access this.
+void QNetworkAccessBackend::emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal)
{
+ reply->emitUploadProgress(bytesSent, bytesTotal);
}
-void QNetworkAccessBackend::upstreamReadyRead()
+QNetworkAccessBackend::QNetworkAccessBackend()
+{
+}
+
+QNetworkAccessBackend::~QNetworkAccessBackend()
{
- // do nothing
}
void QNetworkAccessBackend::downstreamReadyWrite()
@@ -184,23 +212,6 @@ bool QNetworkAccessBackend::isCachingEnabled() const
return reply->isCachingEnabled();
}
-qint64 QNetworkAccessBackend::upstreamBytesAvailable() const
-{
- return reply->writeBuffer.size();
-}
-
-void QNetworkAccessBackend::upstreamBytesConsumed(qint64 count)
-{
- // remove count bytes from the write buffer
- reply->consume(count);
-}
-
-QByteArray QNetworkAccessBackend::readUpstream()
-{
- // ### this is expensive. Consider making QRingBuffer::peekAll keep the buffer it returns
- return reply->writeBuffer.peek(upstreamBytesAvailable());
-}
-
qint64 QNetworkAccessBackend::nextDownstreamBlockSize() const
{
return reply->nextDownstreamBlockSize();
@@ -213,12 +224,12 @@ qint64 QNetworkAccessBackend::downstreamBytesToConsume() const
void QNetworkAccessBackend::writeDownstreamData(const QByteArray &data)
{
- reply->feed(data);
+ reply->appendDownstreamData(data);
}
void QNetworkAccessBackend::writeDownstreamData(QIODevice *data)
{
- reply->feed(data);
+ reply->appendDownstreamData(data);
}
QVariant QNetworkAccessBackend::header(QNetworkRequest::KnownHeaders header) const