summaryrefslogtreecommitdiffstats
path: root/src/core/url_request_context_getter_qt.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-04-28 12:59:40 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-05-03 22:39:30 +0000
commitd107266cd403416d622948186968106a9cf78590 (patch)
tree46be19d204f577fd15df8ba72e6b3094d629b307 /src/core/url_request_context_getter_qt.h
parenta6a8cf1cb1515ec19c5216f76e887c5eef84aef3 (diff)
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 <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/core/url_request_context_getter_qt.h')
-rw-r--r--src/core/url_request_context_getter_qt.h39
1 files changed, 31 insertions, 8 deletions
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 <QtCore/qglobal.h>
#include <QtCore/qatomic.h>
+#include <QtCore/qmutex.h>
#include <QtCore/qsharedpointer.h>
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<BrowserContextAdapter> 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<QByteArray> customSchemes);
+ void regenerateJobFactory();
void cancelAllUrlRequests();
net::HttpNetworkSession::Params generateNetworkSessionParams();
+ void setFullConfiguration(QSharedPointer<BrowserContextAdapter> browserContext);
+
bool m_ignoreCertificateErrors;
- QAtomicInt m_updateCookieStore;
- QAtomicInt m_updateHttpCache;
- QAtomicInt m_updateJobFactory;
- QSharedPointer<BrowserContextAdapter> m_browserContext;
+
+ QMutex m_mutex;
+ bool m_contextInitialized;
+ bool m_updateAllStorage;
+ bool m_updateCookieStore;
+ bool m_updateHttpCache;
+ bool m_updateJobFactory;
+ bool m_updateUserAgent;
+
+ QWeakPointer<BrowserContextAdapter> m_browserContext;
content::ProtocolHandlerMap m_protocolHandlers;
QAtomicPointer<net::ProxyConfigService> m_proxyConfigService;
@@ -109,7 +119,20 @@ private:
scoped_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory;
scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
content::URLRequestInterceptorScopedVector m_requestInterceptors;
+
QList<QByteArray> 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<QByteArray> m_customUrlSchemes;
friend class NetworkDelegateQt;
};