From d107266cd403416d622948186968106a9cf78590 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 28 Apr 2016 12:59:40 +0200 Subject: Fix threading issues with URLRequestContext URLRequestContextGetterQt contains data which is shared between UI and IO thread. Make the class more thread friendly by making copies of the data that can be accessed from the IO thread, and protect synchronization with a full mutex instead of atomics. Also fixes circular reference between URLRequestContextGetterQt and BrowserContextAdapter. Task-number: QTBUG-50160 Task-number: QTBUG-52509 Change-Id: Idaba211533cfad229e1d1872cdfdf4e7dffeb3d8 Reviewed-by: Joerg Bornemann --- src/core/url_request_context_getter_qt.h | 39 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'src/core/url_request_context_getter_qt.h') diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h index b925232a6..11c3f4e79 100644 --- a/src/core/url_request_context_getter_qt.h +++ b/src/core/url_request_context_getter_qt.h @@ -52,9 +52,10 @@ #include "cookie_monster_delegate_qt.h" #include "network_delegate_qt.h" +#include "browser_context_adapter.h" -#include #include +#include #include namespace net { @@ -64,8 +65,7 @@ class ProxyConfigService; namespace QtWebEngineCore { -class BrowserContextAdapter; - +// FIXME: This class should be split into a URLRequestContextGetter and a ProfileIOData, similar to what chrome does. class URLRequestContextGetterQt : public net::URLRequestContextGetter { public: URLRequestContextGetterQt(QSharedPointer browserContext, content::ProtocolHandlerMap *protocolHandlers, content::URLRequestInterceptorScopedVector request_interceptors); @@ -79,25 +79,35 @@ public: void updateCookieStore(); void updateHttpCache(); void updateJobFactory(); + void updateRequestInterceptor(); private: virtual ~URLRequestContextGetterQt(); // Called on the IO thread: + void generateAllStorage(); void generateStorage(); void generateCookieStore(); void generateHttpCache(); void generateUserAgent(); void generateJobFactory(); - void regenerateJobFactory(const QList customSchemes); + void regenerateJobFactory(); void cancelAllUrlRequests(); net::HttpNetworkSession::Params generateNetworkSessionParams(); + void setFullConfiguration(QSharedPointer browserContext); + bool m_ignoreCertificateErrors; - QAtomicInt m_updateCookieStore; - QAtomicInt m_updateHttpCache; - QAtomicInt m_updateJobFactory; - QSharedPointer m_browserContext; + + QMutex m_mutex; + bool m_contextInitialized; + bool m_updateAllStorage; + bool m_updateCookieStore; + bool m_updateHttpCache; + bool m_updateJobFactory; + bool m_updateUserAgent; + + QWeakPointer m_browserContext; content::ProtocolHandlerMap m_protocolHandlers; QAtomicPointer m_proxyConfigService; @@ -109,7 +119,20 @@ private: scoped_ptr m_dhcpProxyScriptFetcherFactory; scoped_refptr m_cookieDelegate; content::URLRequestInterceptorScopedVector m_requestInterceptors; + QList m_installedCustomSchemes; + QWebEngineUrlRequestInterceptor* m_requestInterceptor; + + // Configuration values to setup URLRequestContext in IO thread, copied from browserContext + // FIXME: Should later be moved to a separate ProfileIOData class. + BrowserContextAdapter::PersistentCookiesPolicy m_persistentCookiesPolicy; + QString m_cookiesPath; + QString m_httpAcceptLanguage; + QString m_httpUserAgent; + BrowserContextAdapter::HttpCacheType m_httpCacheType; + QString m_httpCachePath; + int m_httpCacheMaxSize; + QList m_customUrlSchemes; friend class NetworkDelegateQt; }; -- cgit v1.2.3