[Pkg-owncloud-commits] [owncloud-client] 233/333: Add a duration and the repsonse timestamp to the jobs.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:57 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 505429b58215159882bf86bb18cef7e6d00782ce
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Wed Mar 26 17:58:32 2014 +0100

    Add a duration and the repsonse timestamp to the jobs.
---
 src/mirall/networkjobs.cpp     | 19 +++++++++++++++++++
 src/mirall/networkjobs.h       |  8 ++++++++
 src/mirall/propagator_qnam.cpp |  7 ++++++-
 src/mirall/propagator_qnam.h   |  1 +
 src/mirall/propagatorjobs.cpp  | 12 ++++++++++++
 5 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/src/mirall/networkjobs.cpp b/src/mirall/networkjobs.cpp
index 9b6f5b5..4c2a6bf 100644
--- a/src/mirall/networkjobs.cpp
+++ b/src/mirall/networkjobs.cpp
@@ -42,6 +42,7 @@ namespace Mirall {
 
 AbstractNetworkJob::AbstractNetworkJob(Account *account, const QString &path, QObject *parent)
     : QObject(parent)
+    , _duration(0)
     , _ignoreCredentialFailure(false)
     , _reply(0)
     , _account(account)
@@ -133,6 +134,8 @@ QNetworkReply *AbstractNetworkJob::headRequest(const QUrl &url)
 
 void AbstractNetworkJob::slotFinished()
 {
+    _timer.stop();
+
     if( _reply->error() != QNetworkReply::NoError ) {
         qDebug() << Q_FUNC_INFO << _reply->error() << _reply->errorString();
         if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) {
@@ -140,6 +143,11 @@ void AbstractNetworkJob::slotFinished()
         }
         emit networkError(_reply);
     }
+
+    // get the Date timestamp from reply
+    _responseTimestamp = QString::fromAscii(_reply->rawHeader("Date"));
+    _duration = _durationTimer.elapsed();
+
     finished();
     AbstractCredentials *creds = _account->credentials();
     if (!creds->stillValid(_reply) &&! _ignoreCredentialFailure
@@ -159,6 +167,16 @@ void AbstractNetworkJob::slotFinished()
     deleteLater();
 }
 
+quint64 AbstractNetworkJob::duration()
+{
+    return _duration;
+}
+
+QString AbstractNetworkJob::responseTimestamp()
+{
+    return _responseTimestamp;
+}
+
 AbstractNetworkJob::~AbstractNetworkJob() {
     _reply->deleteLater();
 }
@@ -167,6 +185,7 @@ void AbstractNetworkJob::start()
 {
     _timer.start();
     _durationTimer.start();
+    _duration = 0;
 
     qDebug() << "!!!" << metaObject()->className() << "created for" << account()->url() << "querying" << path();
 }
diff --git a/src/mirall/networkjobs.h b/src/mirall/networkjobs.h
index 9ca4157..99407f6 100644
--- a/src/mirall/networkjobs.h
+++ b/src/mirall/networkjobs.h
@@ -20,6 +20,8 @@
 #include <QNetworkRequest>
 #include <QNetworkReply>
 #include <QPointer>
+#include <QElapsedTimer>
+#include <QDateTime>
 #include <QTimer>
 
 class QUrl;
@@ -66,6 +68,9 @@ public:
     void setIgnoreCredentialFailure(bool ignore);
     bool ignoreCredentialFailure() const { return _ignoreCredentialFailure; }
 
+    QString responseTimestamp();
+    quint64 duration();
+
 signals:
     void networkError(QNetworkReply *reply);
 protected:
@@ -83,6 +88,9 @@ protected:
 
     int maxRedirects() const { return 10; }
     virtual void finished() = 0;
+    QString       _responseTimestamp;
+    QElapsedTimer _durationTimer;
+    quint64       _duration;
 
 private slots:
     void slotFinished();
diff --git a/src/mirall/propagator_qnam.cpp b/src/mirall/propagator_qnam.cpp
index 4c44eeb..f30c521 100644
--- a/src/mirall/propagator_qnam.cpp
+++ b/src/mirall/propagator_qnam.cpp
@@ -93,6 +93,7 @@ void PropagateUploadFileQNAM::start()
     }
 
     _currentChunk = 0;
+    _duration.start();
 
     _propagator->_activeJobs++;
     emit progress(_item, 0);
@@ -250,13 +251,14 @@ void PropagateUploadFileQNAM::slotPutFinished()
 
     _item._etag = parseEtag(job->reply()->rawHeader("ETag"));
 
-
     if (job->reply()->rawHeader("X-OC-MTime") != "accepted") {
         //FIXME
 //             updateMTimeAndETag(uri.data(), _item._modtime);
         done(SyncFileItem::NormalError, tr("No X-OC-MTime extension,  ownCloud 5 is required"));
         return;
     }
+    _item._requestDuration = _duration.elapsed();
+    _item._responseTimeStamp = _job->responseTimestamp();
 
     _propagator->_journal->setFileRecord(SyncJournalFileRecord(_item, _propagator->_localDir + _item._file));
     // Remove from the progress database:
@@ -449,6 +451,9 @@ void PropagateDownloadFileQNAM::slotGetFinished()
     }
 
     _item._etag = parseEtag(job->reply()->rawHeader("Etag"));
+    _item._requestDuration = job->duration();
+    _item._responseTimeStamp = job->responseTimestamp();
+
     _tmpFile.close();
     _tmpFile.flush();
     downloadFinished();
diff --git a/src/mirall/propagator_qnam.h b/src/mirall/propagator_qnam.h
index ca76c22..9c694e5 100644
--- a/src/mirall/propagator_qnam.h
+++ b/src/mirall/propagator_qnam.h
@@ -80,6 +80,7 @@ class PropagateUploadFileQNAM : public PropagateItemJob {
     int _currentChunk;
     int _chunkCount;
     int _transferId;
+    QElapsedTimer _duration;
 public:
     PropagateUploadFileQNAM(OwncloudPropagator* propagator,const SyncFileItem& item)
         : PropagateItemJob(propagator, item), _startChunk(0), _currentChunk(0), _chunkCount(0), _transferId(0) {}
diff --git a/src/mirall/propagatorjobs.cpp b/src/mirall/propagatorjobs.cpp
index 0a951a1..61e3d85 100644
--- a/src/mirall/propagatorjobs.cpp
+++ b/src/mirall/propagatorjobs.cpp
@@ -135,6 +135,10 @@ void PropagateRemoteRemove::start()
         return;
     }
 
+    //  Wed, 15 Nov 1995 06:25:24 GMT
+    QDateTime dt = QDateTime::currentDateTimeUtc();
+    _item._responseTimeStamp = dt.toString("ddd, dd MMM yyyy hh:mm:ss GMT");
+
     _propagator->_journal->deleteFileRecord(_item._originalFile, _item._isDirectory);
     _propagator->_journal->commit("Remote Remove");
     done(SyncFileItem::Success);
@@ -152,9 +156,14 @@ void PropagateRemoteMkdir::start()
 
     /* Special for mkcol: it returns 405 if the directory already exists.
      * Ignore that error */
+    //  Wed, 15 Nov 1995 06:25:24 GMT
+    QDateTime dt = QDateTime::currentDateTimeUtc();
+    _item._responseTimeStamp = dt.toString("ddd, dd MMM yyyy hh:mm:ss GMT");
+
     if( updateErrorFromSession( rc , 0, 405 ) ) {
         return;
     }
+
     done(SyncFileItem::Success);
 }
 
@@ -237,6 +246,9 @@ void PropagateRemoteRename::start()
         if (!updateMTimeAndETag(uri2.data(), _item._modtime))
             return;
     }
+    //  Wed, 15 Nov 1995 06:25:24 GMT
+    QDateTime dt = QDateTime::currentDateTimeUtc();
+    _item._responseTimeStamp = dt.toString("ddd, dd MMM yyyy hh:mm:ss GMT");
 
     _propagator->_journal->deleteFileRecord(_item._originalFile);
     SyncJournalFileRecord record(_item, _propagator->_localDir + _item._renameTarget);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list