diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp index 5460e083f54c4df8a489ad0758c94a0df6aa3bf3..609be75d3ad27aeb47b6f13d92a8863c3ef1076d 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() diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h index c7a4366ec541d2586d93778f067a51298bed0254..247247f7c4aa136604d5d7daf41b2a1b0e25b5cc 100644 --- a/src/core/url_request_context_getter_qt.h +++ b/src/core/url_request_context_getter_qt.h @@ -45,6 +45,7 @@ #include "base/single_thread_task_runner.h" #include "content/public/browser/content_browser_client.h" #include "content/public/common/url_constants.h" +#include "net/http/http_network_session.h" #include "net/url_request/url_request_context_storage.h" #include "net/url_request/url_request_job_factory_impl.h" #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" @@ -86,6 +87,8 @@ private: void generateHttpCache(); void generateUserAgent(); void generateJobFactory(); + void cancelAllUrlRequests(); + net::HttpNetworkSession::Params generateNetworkSessionParams(); bool m_ignoreCertificateErrors; QAtomicInt m_updateCookieStore; diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index 57631c4cca1ccf7d46c6371a697852a5f0c61276..9871ecfb1e87a90c871c14bee4e1b9a678d7b272 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -290,6 +290,12 @@ void RenderWidgetHostViewQtDelegateWidget::initializeGL() m_sgRenderer.reset(m_sgEngine->createRenderer()); m_sgRenderer->setRootNode(m_rootNode.data()); m_sgRenderer->setClearColor(m_clearColor); + + // When RenderWidgetHostViewQt::GetScreenInfo is called for the first time, the associated + // QWindow is NULL, and the screen device pixel ratio can not be queried. + // Re-initialize the screen information after the QWindow handle is available, + // so Chromium receives the correct device pixel ratio. + m_client->windowChanged(); } void RenderWidgetHostViewQtDelegateWidget::paintGL() diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf index 2c75f49845f9423f48c8855fc02ca22565af520d..2447d83721d1222b0d7363cb4c7fafb1e7e6102b 100644 --- a/tools/qmake/mkspecs/features/functions.prf +++ b/tools/qmake/mkspecs/features/functions.prf @@ -180,8 +180,12 @@ defineReplace(findOrBuildNinja) { log("Build directory is different from source directory - copying ninja sources to the build tree...") shadow_3rd_party_path = $$system_path($$shadowed($$src_3rd_party_dir)) - !exists($$dirname(out)): mkpath($$shadow_3rd_party_path) - system("$$QMAKE_COPY_DIR $$system_quote($$system_path($$absolute_path("ninja", "$$src_3rd_party_dir"))) $$system_quote($$shadow_3rd_party_path)") + !exists($$dirname(out)): mkpath($$dirname(out)) + copy_dir_files { + system("$$QMAKE_COPY_DIR $$system_quote($$system_path($$absolute_path("ninja", "$$src_3rd_party_dir"))) $$system_quote($$dirname(out))") + } else { + system("$$QMAKE_COPY_DIR $$system_quote($$system_path($$absolute_path("ninja", "$$src_3rd_party_dir"))) $$system_quote($$shadow_3rd_party_path)") + } } system("cd $$system_quote($$dirname(out)) && python configure.py --bootstrap") }