| Index: third_party/WebKit/Source/platform/network/NetworkHints.cpp
|
| diff --git a/third_party/WebKit/Source/platform/network/NetworkHints.cpp b/third_party/WebKit/Source/platform/network/NetworkHints.cpp
|
| index c2c99f7c232bf9945552c288d0cd6cb31acfedc8..f780329c63b9c5b859466000510ef3e61eddc5c9 100644
|
| --- a/third_party/WebKit/Source/platform/network/NetworkHints.cpp
|
| +++ b/third_party/WebKit/Source/platform/network/NetworkHints.cpp
|
| @@ -27,11 +27,12 @@
|
| #include "platform/network/NetworkHints.h"
|
|
|
| #include "public/platform/Platform.h"
|
| +#include "public/platform/ServiceRegistry.h"
|
| #include "public/platform/WebPrescientNetworking.h"
|
|
|
| namespace blink {
|
|
|
| -void prefetchDNS(const String& hostname)
|
| +void speculativePrefetchDNS(const String& hostname)
|
| {
|
| if (WebPrescientNetworking* prescientNetworking = Platform::current()->prescientNetworking())
|
| prescientNetworking->prefetchDNS(hostname);
|
| @@ -39,10 +40,36 @@ void prefetchDNS(const String& hostname)
|
|
|
| void preconnect(const KURL& url, const CrossOriginAttributeValue crossOrigin)
|
| {
|
| - if (WebPrescientNetworking* prescientNetworking = Platform::current()->prescientNetworking()) {
|
| - bool allowCredentials = (crossOrigin != CrossOriginAttributeAnonymous);
|
| - prescientNetworking->preconnect(url, allowCredentials);
|
| - }
|
| + ResourceHintsDispatcher::instance().preconnect(url, crossOrigin, 1);
|
| +}
|
| +
|
| +void prefetchDNS(const KURL& url)
|
| +{
|
| + ResourceHintsDispatcher::instance().preresolve(url);
|
| +}
|
| +
|
| +// static
|
| +ResourceHintsDispatcher& ResourceHintsDispatcher::instance()
|
| +{
|
| + DEFINE_STATIC_LOCAL(ResourceHintsDispatcher, dispatcher, ());
|
| + return dispatcher;
|
| +}
|
| +
|
| +void ResourceHintsDispatcher::preconnect(const KURL& url, CrossOriginAttributeValue crossOrigin, int numConnections)
|
| +{
|
| + bool credentialsFlag = (crossOrigin != CrossOriginAttributeAnonymous);
|
| + m_host->DispatchPreconnect(url, credentialsFlag, numConnections);
|
| +}
|
| +
|
| +void ResourceHintsDispatcher::preresolve(const KURL& url)
|
| +{
|
| + m_host->DispatchPreresolve(url);
|
| +}
|
| +
|
| +ResourceHintsDispatcher::ResourceHintsDispatcher()
|
| +{
|
| + DCHECK(!m_host.is_bound());
|
| + Platform::current()->serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_host));
|
| }
|
|
|
| } // namespace blink
|
|
|