summaryrefslogtreecommitdiffstats
path: root/src/core/content_browser_client_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-07-24 12:32:25 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-01 15:29:51 +0000
commit6a5f8d69fc1d090326fa92a0b24bd494369c2d0d (patch)
treec5d21e50d796a110eb7345bd691d3ba11065528c /src/core/content_browser_client_qt.cpp
parentb80a0ef3c1af16ba74c2b9e931c18266362ce926 (diff)
Add DNS prefetching
Turns out we did no have DNS prefetching. It requires an extra component. The same component can also do pre-connect, but we do not enable that, as it requires a predictive browsing backend. [ChangeLog][Settings] DnsPrefetchEnabled added, but disabled by default. Change-Id: Ieb036435b9f1a72a7be302e38e89e0c347c7176b Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'src/core/content_browser_client_qt.cpp')
-rw-r--r--src/core/content_browser_client_qt.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index a7a2605eb..2d4ac3552 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -49,6 +49,7 @@
#include "components/spellcheck/browser/spellcheck_message_filter_platform.h"
#endif
#endif
+#include "components/network_hints/browser/network_hints_message_filter.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/common/url_schemes.h"
#include "content/public/browser/browser_main_parts.h"
@@ -410,6 +411,11 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost*
{
const int id = host->GetID();
Profile *profile = Profile::FromBrowserContext(host->GetBrowserContext());
+ content::BrowserThread::PostTaskAndReplyWithResult(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&net::URLRequestContextGetter::GetURLRequestContext, base::Unretained(profile->GetRequestContext())),
+ base::Bind(&ContentBrowserClientQt::AddNetworkHintsMessageFilter, base::Unretained(this), id));
+
// FIXME: Add a settings variable to enable/disable the file scheme.
content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(id, url::kFileScheme);
static_cast<ProfileQt*>(host->GetBrowserContext())->m_profileAdapter->userResourceController()->renderProcessStartedWithHost(host);
@@ -776,6 +782,19 @@ void ContentBrowserClientQt::GetGeolocationRequestContext(
base::BindOnce(&GetSystemRequestContextOnUIThread), std::move(callback));
}
+void ContentBrowserClientQt::AddNetworkHintsMessageFilter(int render_process_id, net::URLRequestContext *context)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ content::RenderProcessHost* host = content::RenderProcessHost::FromID(render_process_id);
+ if (!host)
+ return;
+
+ content::BrowserMessageFilter *network_hints_message_filter(
+ new network_hints::NetworkHintsMessageFilter(context->host_resolver()));
+ host->AddFilter(network_hints_message_filter);
+}
+
bool ContentBrowserClientQt::AllowGetCookie(const GURL &url,
const GURL &first_party,
const net::CookieList & /*cookie_list*/,