summaryrefslogtreecommitdiffstats
path: root/src/core/url_request_custom_job.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-05-05 16:34:14 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-05-06 17:30:50 +0000
commit8596813a10b66b539746bb890bd4304e5f65b348 (patch)
treee2a347c64e7bd005af1ac3036c2d8b40184ebeea /src/core/url_request_custom_job.h
parenteed2622ebc3298ec533d298fc7798a3690d2440c (diff)
Improve thread safety and behavior of custom URL requests
Adds thread protection between the UI and IO threads access to the QIODevice, and changes it to a QPointer, so we can tell if the user deletes it. Change-Id: I3e7b3f682d4c5a145d75cd5822affcfc9012cff7 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/core/url_request_custom_job.h')
-rw-r--r--src/core/url_request_custom_job.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/core/url_request_custom_job.h b/src/core/url_request_custom_job.h
index 448bfe6af..ca20c719d 100644
--- a/src/core/url_request_custom_job.h
+++ b/src/core/url_request_custom_job.h
@@ -41,6 +41,8 @@
#include "net/url_request/url_request_job.h"
#include <QtCore/qglobal.h>
+#include <QtCore/QMutex>
+#include <QtCore/QPointer>
QT_FORWARD_DECLARE_CLASS(QIODevice)
@@ -63,19 +65,27 @@ public:
void setReplyCharset(const std::string &);
void setReplyDevice(QIODevice *);
+ void fail(int);
+
protected:
virtual ~URLRequestCustomJob();
void startAsync();
void notifyStarted();
+ void notifyFailure();
private:
- QIODevice *m_device;
- scoped_ptr<URLRequestCustomJobDelegate> m_delegate;
+ QMutex m_mutex;
+ QPointer<QIODevice> m_device;
+ QPointer<URLRequestCustomJobDelegate> m_delegate;
CustomUrlSchemeHandler *m_schemeHandler;
std::string m_mimeType;
std::string m_charset;
+ int m_error;
+ bool m_started;
base::WeakPtrFactory<URLRequestCustomJob> m_weakFactory;
+ friend class URLRequestCustomJobDelegate;
+
DISALLOW_COPY_AND_ASSIGN(URLRequestCustomJob);
};