static void preconnectIfNeeded( const LinkRelAttribute& relAttribute, const KURL& href, Document& document, const CrossOriginAttributeValue crossOrigin, const NetworkHintsInterface& networkHintsInterface, LinkCaller caller) { if (relAttribute.isPreconnect() && href.isValid() && href.protocolIsInHTTPFamily()) { UseCounter::count(document, UseCounter::LinkRelPreconnect); if (caller == LinkCalledFromHeader) UseCounter::count(document, UseCounter::LinkHeaderPreconnect); Settings* settings = document.settings(); if (settings && settings->logDnsPrefetchAndPreconnect()) { document.addConsoleMessage(ConsoleMessage::create( OtherMessageSource, DebugMessageLevel, String("Preconnect triggered for ") + href.getString())); if (crossOrigin != CrossOriginAttributeNotSet) { document.addConsoleMessage(ConsoleMessage::create( OtherMessageSource, DebugMessageLevel, String("Preconnect CORS setting is ") + String((crossOrigin == CrossOriginAttributeAnonymous) ? "anonymous" : "use-credentials"))); } } networkHintsInterface.preconnectHost(href, crossOrigin); } }
static void dnsPrefetchIfNeeded( const LinkRelAttribute& relAttribute, const KURL& href, Document& document, const NetworkHintsInterface& networkHintsInterface, LinkCaller caller) { if (relAttribute.isDNSPrefetch()) { UseCounter::count(document, UseCounter::LinkRelDnsPrefetch); if (caller == LinkCalledFromHeader) UseCounter::count(document, UseCounter::LinkHeaderDnsPrefetch); Settings* settings = document.settings(); // FIXME: The href attribute of the link element can be in "//hostname" // form, and we shouldn't attempt to complete that as URL // <https://bugs.webkit.org/show_bug.cgi?id=48857>. if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && !href.isEmpty()) { if (settings->logDnsPrefetchAndPreconnect()) { document.addConsoleMessage(ConsoleMessage::create( OtherMessageSource, DebugMessageLevel, String("DNS prefetch triggered for " + href.host()))); } networkHintsInterface.dnsPrefetchHost(href.host()); } } }
static void preconnectHost(PreloadRequest* request, const NetworkHintsInterface& networkHintsInterface) { ASSERT(request); ASSERT(request->isPreconnect()); KURL host(request->baseURL(), request->resourceURL()); if (!host.isValid() || !host.protocolIsInHTTPFamily()) return; networkHintsInterface.preconnectHost(host, request->crossOrigin()); }