* No need to initialize values in the QWebNetworkJob c'tor
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Oct 2007 13:41:08 +0000 (13:41 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Oct 2007 13:41:08 +0000 (13:41 +0000)
* Add a JobStatus to QWebNetworkJob and verify that the jobs are handled in the way we expect them to be handled. This means no data after the job has finished, not finishing a job before it has been started.

Signed-off-by: Simon Hausmann <hausmann@kde.org>
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27041 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebnetworkinterface.cpp
WebKit/qt/Api/qwebnetworkinterface.h
WebKit/qt/Api/qwebnetworkinterface_p.h
WebKit/qt/ChangeLog

index a87799d2598bc398b40ba404200f444632e985d5..8839ef7845361c678849dd8b98ca78457bf17e0e 100644 (file)
@@ -283,9 +283,6 @@ void QWebNetworkRequest::setPostData(const QByteArray &data)
 QWebNetworkJob::QWebNetworkJob()
     : d(new QWebNetworkJobPrivate)
 {
-    d->ref = 1;
-    d->redirected = false;
-    d->interface = 0;
 }
 
 /*!
@@ -400,6 +397,16 @@ QWebFrame *QWebNetworkJob::frame() const
     return 0;
 }
 
+QWebNetworkJob::JobStatus QWebNetworkJob::status() const
+{
+    return d->jobStatus;
+}
+
+void QWebNetworkJob::setStatus(const JobStatus& status)
+{
+    d->jobStatus = status;
+}
+
 /*!
   \class QWebNetworkManager
   \internal
@@ -468,7 +475,10 @@ void QWebNetworkManager::cancel(ResourceHandle *handle)
 void QWebNetworkManager::started(QWebNetworkJob *job)
 {
     Q_ASSERT(job->d);
+    Q_ASSERT(job->status() == QWebNetworkJob::JobCreated ||
+             job->status() == QWebNetworkJob::JobRecreated);
 
+    job->setStatus(QWebNetworkJob::JobStarted);
     ResourceHandleClient* client = 0;
     if (job->d->resourceHandle) {
         client = job->d->resourceHandle->client();
@@ -552,6 +562,10 @@ void QWebNetworkManager::started(QWebNetworkJob *job)
 
 void QWebNetworkManager::data(QWebNetworkJob *job, const QByteArray &data)
 {
+    Q_ASSERT(job->status() == QWebNetworkJob::JobStarted ||
+             job->status() == QWebNetworkJob::JobReceivingData);
+
+    job->setStatus(QWebNetworkJob::JobReceivingData);
     ResourceHandleClient* client = 0;
     if (job->d->resourceHandle) {
         client = job->d->resourceHandle->client();
@@ -574,9 +588,13 @@ void QWebNetworkManager::data(QWebNetworkJob *job, const QByteArray &data)
 
 void QWebNetworkManager::finished(QWebNetworkJob *job, int errorCode)
 {
+    Q_ASSERT(job->status() == QWebNetworkJob::JobStarted ||
+             job->status() == QWebNetworkJob::JobReceivingData);
+
     if (m_synchronousJobs.contains(job))
         m_synchronousJobs.remove(job);
 
+    job->setStatus(QWebNetworkJob::JobFinished);
     ResourceHandleClient* client = 0;
     if (job->d->resourceHandle) {
         client = job->d->resourceHandle->client();
@@ -591,6 +609,7 @@ void QWebNetworkManager::finished(QWebNetworkJob *job, int errorCode)
 
     if (job->d->redirected) {
         job->d->redirected = false;
+        job->setStatus(QWebNetworkJob::JobRecreated);
         job->d->interface->addJob(job);
         return;
     }
index 0d9cc4953f1ab7f5f10f4e34cebef2996e504f2d..2cf1dabb9faac74e711950386e92fac460a1f879 100644 (file)
@@ -85,6 +85,7 @@ private:
 class QWEBKIT_EXPORT QWebNetworkJob
 {
 public:
+
     QUrl url() const;
     QByteArray postData() const;
     QHttpRequestHeader httpHeader() const;
@@ -102,12 +103,25 @@ public:
     
     QWebFrame *frame() const;
 
+protected:
+    enum JobStatus {
+        JobCreated,
+        JobRecreated,
+        JobStarted,
+        JobReceivingData,
+        JobFinished
+    };
+
+    JobStatus status() const;
+    void setStatus(const JobStatus&);
+
 private:
     QWebNetworkJob();
     ~QWebNetworkJob();
 
     friend class QWebNetworkManager;
     friend class QWebObjectPluginConnector;
+    friend class QWebNetworkJobPrivate;
 
     QWebNetworkJobPrivate *d;
 };
index b097efa4698b63f053310c0b94ca6c669f4a7add..c49602ae1760885ac595004db8a414441b525c0a 100644 (file)
@@ -57,6 +57,7 @@ public:
         , redirected(false)
         , interface(0)
         , connector(0)
+        , jobStatus(QWebNetworkJob::JobCreated)
         {}
     int ref;
 
@@ -68,6 +69,7 @@ public:
 
     QWebNetworkInterface *interface;
     QWebObjectPluginConnector *connector;
+    QWebNetworkJob::JobStatus jobStatus;
 };
 
 class QWebNetworkManager : public QObject
index 1addb7b3e556c7776a94be5344da4778d79a554c..48bea507bed87a2a0bffea1e4893a8a966ed18a7 100644 (file)
@@ -1,3 +1,21 @@
+2007-10-25  Holger Freyther  <zecke@selfish.org>
+
+        Reviewed by Simon Hausmann <hausmann@kde.org>.
+
+        * No need to initialize values in the QWebNetworkJob c'tor
+        * Add a JobStatus to QWebNetworkJob and verify that the jobs are handled in the way we expect them to be handled. This means no data after the job has finished, not finishing a job before it has been started.
+        
+
+        * Api/qwebnetworkinterface.cpp:
+        (QWebNetworkJob::status):
+        (QWebNetworkJob::setStatus):
+        (QWebNetworkManager::started):
+        (QWebNetworkManager::data):
+        (QWebNetworkManager::finished):
+        * Api/qwebnetworkinterface.h:
+        * Api/qwebnetworkinterface_p.h:
+        (QWebNetworkJobPrivate::QWebNetworkJobPrivate):
+
 2007-10-25  Holger Freyther  <zecke@selfish.org>
 
         Reviewed by Simon Hausmann <hausmann@kde.org>.