From 73286f99b4ecc3f11485e36b1a090849e5efd4ef Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 4 Sep 2017 16:00:47 +0200 Subject: Simplify URLRequestCustomJob handling Improve implementation of URLRequestCustomJob: * remove qmutex, pass values using PostTask * do not use base::WeakPtr which is not thread safe and must always be dereferenced on the same thread * add proxy object to handle interactions between threads * do not use QPointer to track IODevice since it does not solve anything for us * QIODevice in reply method is used only by IO thread * do not make shared object to commit suicide, instead use refcounted object * improve documentation about thread safety issue of QIODevice object in reply method Change-Id: Ic29bf262de8082dfd46cb9217a68f3c982d16b9e Reviewed-by: Leena Miettinen Reviewed-by: Allan Sandfeld Jensen --- src/core/api/qwebengineurlrequestjob.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/core/api/qwebengineurlrequestjob.cpp') diff --git a/src/core/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp index 742bdf527..a071adbd5 100644 --- a/src/core/api/qwebengineurlrequestjob.cpp +++ b/src/core/api/qwebengineurlrequestjob.cpp @@ -115,10 +115,16 @@ QByteArray QWebEngineUrlRequestJob::requestMethod() const /*! Replies to the request with \a device and the MIME type \a contentType. + The user has to be aware that \a device will be used on another thread + until the job is deleted. In case simultaneous access from the main thread + is desired, the user is reponsible for making access to \a device thread-safe + for example by using QMutex. Note that the \a device object is not owned by + the web engine. Therefore, the signal QObject::destroyed() of + QWebEngineUrlRequestJob must be monitored. */ void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *device) { - d_ptr->setReply(contentType, device); + d_ptr->reply(contentType, device); } /*! -- cgit v1.2.1