Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: third_party/WebKit/Source/platform/network/NetworkHints.cpp

Issue 2043753002: Declarative resource hints go through mojo IPC to //content Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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, ());
kinuko 2016/06/09 07:09:19 For platform-level mojo calls I'm still not fully
Charlie Harrison 2016/06/10 14:20:00 Good idea. This will make testing simpler too (I t
+ 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());
yzshen1 2016/06/08 17:40:53 nit: this DCHECK is not very useful because defaul
Charlie Harrison 2016/06/10 14:20:00 Done.
+ Platform::current()->serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_host));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698