summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-10-09 10:03:42 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-10-09 10:04:00 (GMT)
commit606e1150e381e0d824e6850befb101a2ed8e0542 (patch)
tree10a180b6e8013a22e7937f9c78d9636573d7ec83 /src
parent62e7e63779a8dbd5dec16e5eb938bf597bc22548 (diff)
downloadQt-606e1150e381e0d824e6850befb101a2ed8e0542.zip
Qt-606e1150e381e0d824e6850befb101a2ed8e0542.tar.gz
Qt-606e1150e381e0d824e6850befb101a2ed8e0542.tar.bz2
Add a way to allow tracking the originating object with QNetworkRequest.
Added setOriginatingObject() and originatingObject() to QNetworkRequest that internally tracks the QObject using a QWeakPointer. Reviewed-by: Lars Knoll Rubberstamped-by: Thiago
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qnetworkrequest.cpp30
-rw-r--r--src/network/access/qnetworkrequest.h3
-rw-r--r--src/network/access/qnetworkrequest_p.h2
3 files changed, 35 insertions, 0 deletions
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index cde9858..ca9e606 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -481,6 +481,36 @@ void QNetworkRequest::setSslConfiguration(const QSslConfiguration &config)
}
#endif
+/*!
+ \since 4.6
+
+ Allows setting a reference to the object initiating
+ the request.
+
+ For example QtWebKit sets the originating object to the
+ QWebFrame that initiated the request.
+
+ \sa originatingObject()
+*/
+void QNetworkRequest::setOriginatingObject(QObject *object)
+{
+ d->originatingObject = object;
+}
+
+/*!
+ \since 4.6
+
+ Returns a reference to the object that initiated this
+ network request; returns 0 if not set or the object has
+ been destroyed.
+
+ \sa setOriginatingObject()
+*/
+QObject *QNetworkRequest::originatingObject() const
+{
+ return d->originatingObject.data();
+}
+
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
{
switch (header) {
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index 7b15237..62c6dda 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -120,6 +120,9 @@ public:
void setSslConfiguration(const QSslConfiguration &configuration);
#endif
+ void setOriginatingObject(QObject *object);
+ QObject *originatingObject() const;
+
private:
QSharedDataPointer<QNetworkRequestPrivate> d;
friend class QNetworkRequestPrivate;
diff --git a/src/network/access/qnetworkrequest_p.h b/src/network/access/qnetworkrequest_p.h
index 22b239f..9b3632f 100644
--- a/src/network/access/qnetworkrequest_p.h
+++ b/src/network/access/qnetworkrequest_p.h
@@ -58,6 +58,7 @@
#include "QtCore/qlist.h"
#include "QtCore/qhash.h"
#include "QtCore/qshareddata.h"
+#include "QtCore/qsharedpointer.h"
QT_BEGIN_NAMESPACE
@@ -73,6 +74,7 @@ public:
RawHeadersList rawHeaders;
CookedHeadersMap cookedHeaders;
AttributesMap attributes;
+ QWeakPointer<QObject> originatingObject;
RawHeadersList::ConstIterator findRawHeader(const QByteArray &key) const;
QList<QByteArray> rawHeadersKeys() const;