From a05bb73747620dd8f0294a57ff690a4f4202884e Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 16 Apr 2020 13:20:04 +0200 Subject: Move request interceptor to ui thread We use now network service avoid io-ui-io-ui hops, pipe proxying url loader factory directly to ui thread. This solves thread safty issues. Add deprecated request interceptor test cases. Task-number: QTBUG-83082 Task-number: QTBUG-82999 Change-Id: I38778cf1a70789c5e92e04c93d1c93e2cc4c765a Reviewed-by: Allan Sandfeld Jensen --- src/webenginewidgets/api/qwebenginepage.cpp | 18 +----------------- src/webenginewidgets/api/qwebenginepage_p.h | 2 -- src/webenginewidgets/api/qwebengineprofile.cpp | 1 + 3 files changed, 2 insertions(+), 19 deletions(-) (limited to 'src/webenginewidgets') diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 0d2988421..b267c5dd1 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -163,7 +163,6 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , webChannelWorldId(QWebEngineScript::MainWorld) , defaultAudioMuted(false) , defaultZoomFactor(1.0) - , requestInterceptor(nullptr) #if QT_CONFIG(webengine_printing_and_pdf) , currentPrinter(nullptr) #endif @@ -185,8 +184,6 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) QWebEnginePagePrivate::~QWebEnginePagePrivate() { - if (requestInterceptor) - profile->d_ptr->profileAdapter()->removePageRequestInterceptor(); delete history; delete settings; profile->d_ptr->removeWebContentsAdapterClient(this); @@ -1916,20 +1913,7 @@ void QWebEnginePagePrivate::visibleChanged(bool visible) void QWebEnginePage::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) { Q_D(QWebEnginePage); - bool hadInterceptorChanged = bool(d->requestInterceptor) != bool(interceptor); - d->requestInterceptor = interceptor; - if (hadInterceptorChanged) { - if (interceptor) - d->profile->d_ptr->profileAdapter()->addPageRequestInterceptor(); - else - d->profile->d_ptr->profileAdapter()->removePageRequestInterceptor(); - } -} - -void QWebEnginePagePrivate::interceptRequest(QWebEngineUrlRequestInfo &info) -{ - if (requestInterceptor) - requestInterceptor->interceptRequest(info); + d->adapter->setRequestInterceptor(interceptor); } #if QT_CONFIG(menu) diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 4f33e26f3..f37413b8e 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -161,7 +161,6 @@ public: void hideTouchSelectionMenu() override { } const QObject *holdingQObject() const override; ClientType clientType() override { return QtWebEngineCore::WebContentsAdapterClient::WidgetsClient; } - void interceptRequest(QWebEngineUrlRequestInfo &) override; void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegate *newWidget) override; void findTextFinished(const QWebEngineFindTextResult &result) override; @@ -202,7 +201,6 @@ public: bool defaultAudioMuted; qreal defaultZoomFactor; QTimer wasShownTimer; - QWebEngineUrlRequestInterceptor *requestInterceptor; QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget = nullptr; mutable QtWebEngineCore::CallbackDirectory m_callbacks; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index 470babf8f..4c49be709 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -596,6 +596,7 @@ QWebEngineCookieStore* QWebEngineProfile::cookieStore() 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. + For a duration of this call ui thread is blocked. Use setUrlRequestInterceptor instead. \since 5.6 -- cgit v1.2.3