feat: HTTP preconnect feature minimal for electronjs (#18671)

This commit is contained in:
Kuts Alexey 2019-08-26 19:47:32 +03:00 committed by Jeremy Apthorp
parent c57db7f163
commit cddbddc543
17 changed files with 377 additions and 1 deletions

View file

@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "components/network_hints/renderer/prescient_networking_dispatcher.h"
#include "content/common/buildflags.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
@ -201,6 +202,9 @@ void RendererClientBase::RenderThreadStarted() {
blink::WebSecurityPolicy::RegisterURLSchemeAsAllowingServiceWorkers("file");
blink::SchemeRegistry::RegisterURLSchemeAsSupportingFetchAPI("file");
prescient_networking_dispatcher_.reset(
new network_hints::PrescientNetworkingDispatcher());
#if defined(OS_WIN)
// Set ApplicationUserModelID in renderer process.
base::string16 app_id =
@ -318,6 +322,10 @@ void RendererClientBase::DidSetUserAgent(const std::string& user_agent) {
#endif
}
blink::WebPrescientNetworking* RendererClientBase::GetPrescientNetworking() {
return prescient_networking_dispatcher_.get();
}
void RendererClientBase::RunScriptsAtDocumentStart(
content::RenderFrame* render_frame) {
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)

View file

@ -19,6 +19,10 @@
#include "chrome/renderer/media/chrome_key_systems_provider.h" // nogncheck
#endif
namespace network_hints {
class PrescientNetworkingDispatcher;
}
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
namespace extensions {
class ExtensionsClient;
@ -47,6 +51,7 @@ class RendererClientBase : public content::ContentRendererClient {
content::RenderFrame* render_frame,
int world_id) = 0;
blink::WebPrescientNetworking* GetPrescientNetworking() override;
bool isolated_world() const { return isolated_world_; }
// Get the context that the Electron API is running in.
@ -90,10 +95,14 @@ class RendererClientBase : public content::ContentRendererClient {
#endif
private:
std::unique_ptr<network_hints::PrescientNetworkingDispatcher>
prescient_networking_dispatcher_;
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
std::unique_ptr<AtomExtensionsRendererClient> extensions_renderer_client_;
#endif
#if defined(WIDEVINE_CDM_AVAILABLE)
ChromeKeySystemsProvider key_systems_provider_;
#endif