summaryrefslogtreecommitdiffstats
path: root/src/core/url_request_context_getter_qt.cpp
diff options
context:
space:
mode:
authorMichael Bruning <michael.bruning@theqtcompany.com>2015-12-09 16:13:37 +0100
committerMichael Bruning <michael.bruning@theqtcompany.com>2015-12-09 16:13:37 +0100
commit04b30d974aee4fc556249b1bfa62c7cb79b839c5 (patch)
tree8c287e09e01936c0f482522d5082bbf64bafb786 /src/core/url_request_context_getter_qt.cpp
parent1c09b16ebb88737682a5cd6ddc58f6d360b635af (diff)
parent7c5f2a9393a3fc77c0c5b2406332d57a37325183 (diff)
Merge remote-tracking branch 'origin/5.5' into 5.6
Conflicts: src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp Change-Id: I451bc61673014db8e87b2a2cf98fb6879ce0e58d
Diffstat (limited to 'src/core/url_request_context_getter_qt.cpp')
-rw-r--r--src/core/url_request_context_getter_qt.cpp102
1 files changed, 78 insertions, 24 deletions
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index 5460e083f..609be75d3 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -130,22 +130,29 @@ void URLRequestContextGetterQt::updateStorageSettings()
}
}
-void URLRequestContextGetterQt::generateStorage()
+void URLRequestContextGetterQt::cancelAllUrlRequests()
{
Q_ASSERT(m_urlRequestContext);
- if (m_storage) {
- // We must stop all requests before deleting their backends.
- std::set<const net::URLRequest*>* url_requests = m_urlRequestContext->url_requests();
- std::set<const net::URLRequest*>::const_iterator it = url_requests->begin();
- std::set<const net::URLRequest*>::const_iterator end = url_requests->end();
- for ( ; it != end; ++it) {
- net::URLRequest* request = const_cast<net::URLRequest*>(*it);
- if (request)
- request->Cancel();
- }
+ std::set<const net::URLRequest*>* url_requests = m_urlRequestContext->url_requests();
+ std::set<const net::URLRequest*>::const_iterator it = url_requests->begin();
+ std::set<const net::URLRequest*>::const_iterator end = url_requests->end();
+ for ( ; it != end; ++it) {
+ net::URLRequest* request = const_cast<net::URLRequest*>(*it);
+ if (request)
+ request->Cancel();
}
+}
+
+void URLRequestContextGetterQt::generateStorage()
+{
+ Q_ASSERT(m_urlRequestContext);
+
+ // We must stop all requests before deleting their backends.
+ if (m_storage)
+ cancelAllUrlRequests();
+
m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get()));
net::ProxyConfigService *proxyConfigService = m_proxyConfigService.fetchAndStoreAcquire(0);
@@ -285,11 +292,56 @@ void URLRequestContextGetterQt::updateHttpCache()
}
}
+static bool doNetworkSessionParamsMatch(const net::HttpNetworkSession::Params &first, const net::HttpNetworkSession::Params &second)
+{
+ if (first.transport_security_state != second.transport_security_state)
+ return false;
+ if (first.cert_verifier != second.cert_verifier)
+ return false;
+ if (first.channel_id_service != second.channel_id_service)
+ return false;
+ if (first.proxy_service != second.proxy_service)
+ return false;
+ if (first.ssl_config_service != second.ssl_config_service)
+ return false;
+ if (first.http_auth_handler_factory != second.http_auth_handler_factory)
+ return false;
+ if (first.network_delegate != second.network_delegate)
+ return false;
+ if (first.http_server_properties.get() != second.http_server_properties.get())
+ return false;
+ if (first.ignore_certificate_errors != second.ignore_certificate_errors)
+ return false;
+ if (first.host_resolver != second.host_resolver)
+ return false;
+
+ return true;
+}
+
+net::HttpNetworkSession::Params URLRequestContextGetterQt::generateNetworkSessionParams()
+{
+ Q_ASSERT(m_urlRequestContext);
+
+ net::HttpNetworkSession::Params network_session_params;
+
+ network_session_params.transport_security_state = m_urlRequestContext->transport_security_state();
+ network_session_params.cert_verifier = m_urlRequestContext->cert_verifier();
+ network_session_params.channel_id_service = m_urlRequestContext->channel_id_service();
+ network_session_params.proxy_service = m_urlRequestContext->proxy_service();
+ network_session_params.ssl_config_service = m_urlRequestContext->ssl_config_service();
+ network_session_params.http_auth_handler_factory = m_urlRequestContext->http_auth_handler_factory();
+ network_session_params.network_delegate = m_networkDelegate.get();
+ network_session_params.http_server_properties = m_urlRequestContext->http_server_properties();
+ network_session_params.ignore_certificate_errors = m_ignoreCertificateErrors;
+ network_session_params.host_resolver = m_urlRequestContext->host_resolver();
+
+ return network_session_params;
+}
+
void URLRequestContextGetterQt::generateHttpCache()
{
Q_ASSERT(m_urlRequestContext);
Q_ASSERT(m_storage);
- m_updateHttpCache = 0;
net::HttpCache::DefaultBackend* main_backend = 0;
switch (m_browserContext->httpCacheType()) {
@@ -315,19 +367,21 @@ void URLRequestContextGetterQt::generateHttpCache()
break;
}
- net::HttpNetworkSession::Params network_session_params;
- network_session_params.transport_security_state = m_urlRequestContext->transport_security_state();
- network_session_params.cert_verifier = m_urlRequestContext->cert_verifier();
- network_session_params.channel_id_service = m_urlRequestContext->channel_id_service();
- network_session_params.proxy_service = m_urlRequestContext->proxy_service();
- network_session_params.ssl_config_service = m_urlRequestContext->ssl_config_service();
- network_session_params.http_auth_handler_factory = m_urlRequestContext->http_auth_handler_factory();
- network_session_params.network_delegate = m_networkDelegate.get();
- network_session_params.http_server_properties = m_urlRequestContext->http_server_properties();
- network_session_params.ignore_certificate_errors = m_ignoreCertificateErrors;
- network_session_params.host_resolver = m_urlRequestContext->host_resolver();
+ net::HttpCache *cache = 0;
+ net::HttpNetworkSession *network_session = 0;
+ net::HttpNetworkSession::Params network_session_params = generateNetworkSessionParams();
+
+ if (m_urlRequestContext->http_transaction_factory())
+ network_session = m_urlRequestContext->http_transaction_factory()->GetSession();
- m_storage->set_http_transaction_factory(new net::HttpCache(network_session_params, main_backend));
+ if (!network_session || !doNetworkSessionParamsMatch(network_session_params, network_session->params())) {
+ cancelAllUrlRequests();
+ cache = new net::HttpCache(network_session_params, main_backend);
+ } else
+ cache = new net::HttpCache(network_session, main_backend);
+
+ m_storage->set_http_transaction_factory(cache);
+ m_updateHttpCache = 0;
}
void URLRequestContextGetterQt::generateJobFactory()