summaryrefslogtreecommitdiffstats
path: root/src/core/url_request_context_getter_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-04-15 12:45:59 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-04-20 14:32:58 +0000
commitd56128c315ad89dddf507b10dc4332d05cc42f91 (patch)
tree65a2b340c82350d95cb29a1576e1053d6ba84a0c /src/core/url_request_context_getter_qt.cpp
parent5b8aad9fa24caeb50ff3640d01590a15ee4e23d8 (diff)
Improve thread-safety of custom scheme handlers
Avoids accessing the QWebEngineUrlSchemeHandler from any other thread than the UI thread, since it may be deleted at any time on the UI thread. Change-Id: Icb4331b3c36f6f619a9fd975d155a9fd608dc5e9 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/core/url_request_context_getter_qt.cpp')
-rw-r--r--src/core/url_request_context_getter_qt.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index daa07b54b..dfc647731 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -308,7 +308,6 @@ void URLRequestContextGetterQt::updateHttpCache()
void URLRequestContextGetterQt::updateJobFactory()
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- Q_ASSERT(m_jobFactory);
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestContextGetterQt::generateJobFactory, this));
}
@@ -429,10 +428,9 @@ void URLRequestContextGetterQt::generateJobFactory()
jobFactory->SetProtocolHandler(url::kFtpScheme,
new net::FtpProtocolHandler(new net::FtpNetworkLayer(m_urlRequestContext->host_resolver())));
- QHash<QByteArray, QWebEngineUrlSchemeHandler*>::const_iterator it = m_browserContext->customUrlSchemeHandlers().constBegin();
- const QHash<QByteArray, QWebEngineUrlSchemeHandler*>::const_iterator end = m_browserContext->customUrlSchemeHandlers().constEnd();
- for (; it != end; ++it)
- jobFactory->SetProtocolHandler(it.key().toStdString(), new CustomProtocolHandler(it.value()));
+ Q_FOREACH (const QByteArray &scheme, m_browserContext->customUrlSchemes()) {
+ jobFactory->SetProtocolHandler(scheme.toStdString(), new CustomProtocolHandler(m_browserContext));
+ }
// Set up interceptors in the reverse order.
scoped_ptr<net::URLRequestJobFactory> topJobFactory = jobFactory.Pass();