diff options
author | Michal Klocek <michal.klocek@qt.io> | 2019-02-01 12:01:26 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2019-02-04 15:34:00 +0000 |
commit | 5e92adf5f85c4ec8340d5b7e92166a5e4f8e9883 (patch) | |
tree | 350d28ccf5de9a85cc26f520bd0dda2222bc1021 /src/webengine/api | |
parent | a8b48040243c95316a9dad92360f086cf6e537af (diff) |
Move QWebEngineUrlRequestInterceptor::intercept to ui thread
Currently interceptor sufferers thread safety issues, when
custom profiles are deleted, interceptor is set to be nullptr,
however it can be still referenced in IO thread. Since
profile was split to ui and io part, where io part can outlive
the ui part, this can boost thread safety issues.
Since QWebEngineUrlRequestInterceptor is living on ui thread
simplify the logic move intercept call to ui thread.
This fixes the issue of referencing interceptor in io thread.
Add new method to install interceptor setUrlRequestInterceptor,
and deprecate old one. Update interceptor install method name
on page to match the profile one.
Task-number: QTBUG-69844
Change-Id: I5dd2b6b734fd91906cccc6c1408ffbe7b1b4250c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/webengine/api')
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 27 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.h | 3 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 4448d44d1..8a6c20f67 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -922,20 +922,45 @@ void QQuickWebEngineProfile::clearHttpCache() d->profileAdapter()->clearHttpCache(); } - +#if QT_DEPRECATED_SINCE(5, 13) /*! Registers a request interceptor singleton \a interceptor to intercept URL requests. The profile does not take ownership of the pointer. + \obsolete + + Interceptors installed with this method will call + QWebEngineUrlRequestInterceptor::interceptRequest on the I/O thread. Therefore + the user has to provide thread-safe interaction with the other user classes. + Use setUrlRequestInterceptor instead. + \sa QWebEngineUrlRequestInterceptor + */ void QQuickWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { Q_D(QQuickWebEngineProfile); + interceptor->setProperty("deprecated", true); + d->profileAdapter()->setRequestInterceptor(interceptor); + qWarning("Use of deprecated not tread-safe setter, use setUrlRequestInterceptor instead."); +} +#endif + +/*! + Registers a request interceptor singleton \a interceptor to intercept URL requests. + + The profile does not take ownership of the pointer. + + \sa QWebEngineUrlRequestInfo QWebEngineUrlRequestInterceptor +*/ +void QQuickWebEngineProfile::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) +{ + Q_D(QQuickWebEngineProfile); d->profileAdapter()->setRequestInterceptor(interceptor); } + /*! Returns the custom URL scheme handler register for the URL scheme \a scheme. */ diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h index 1e2e3e030..f4460ba18 100644 --- a/src/webengine/api/qquickwebengineprofile.h +++ b/src/webengine/api/qquickwebengineprofile.h @@ -126,7 +126,10 @@ public: QWebEngineCookieStore *cookieStore() const; +#if QT_DEPRECATED_SINCE(5, 13) void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor); +#endif + void setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor); const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &) const; void installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *); |