| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 const NetworkHintsInterface& networkHintsInterface, | 133 const NetworkHintsInterface& networkHintsInterface, |
| 134 LinkCaller caller) { | 134 LinkCaller caller) { |
| 135 if (relAttribute.isDNSPrefetch()) { | 135 if (relAttribute.isDNSPrefetch()) { |
| 136 UseCounter::count(document, UseCounter::LinkRelDnsPrefetch); | 136 UseCounter::count(document, UseCounter::LinkRelDnsPrefetch); |
| 137 if (caller == LinkCalledFromHeader) | 137 if (caller == LinkCalledFromHeader) |
| 138 UseCounter::count(document, UseCounter::LinkHeaderDnsPrefetch); | 138 UseCounter::count(document, UseCounter::LinkHeaderDnsPrefetch); |
| 139 Settings* settings = document.settings(); | 139 Settings* settings = document.settings(); |
| 140 // FIXME: The href attribute of the link element can be in "//hostname" | 140 // FIXME: The href attribute of the link element can be in "//hostname" |
| 141 // form, and we shouldn't attempt to complete that as URL | 141 // form, and we shouldn't attempt to complete that as URL |
| 142 // <https://bugs.webkit.org/show_bug.cgi?id=48857>. | 142 // <https://bugs.webkit.org/show_bug.cgi?id=48857>. |
| 143 if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && | 143 if (settings && settings->getDNSPrefetchingEnabled() && href.isValid() && |
| 144 !href.isEmpty()) { | 144 !href.isEmpty()) { |
| 145 if (settings->logDnsPrefetchAndPreconnect()) { | 145 if (settings->getLogDnsPrefetchAndPreconnect()) { |
| 146 document.addConsoleMessage(ConsoleMessage::create( | 146 document.addConsoleMessage(ConsoleMessage::create( |
| 147 OtherMessageSource, DebugMessageLevel, | 147 OtherMessageSource, DebugMessageLevel, |
| 148 String("DNS prefetch triggered for " + href.host()))); | 148 String("DNS prefetch triggered for " + href.host()))); |
| 149 } | 149 } |
| 150 networkHintsInterface.dnsPrefetchHost(href.host()); | 150 networkHintsInterface.dnsPrefetchHost(href.host()); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 static void preconnectIfNeeded( | 155 static void preconnectIfNeeded( |
| 156 const LinkRelAttribute& relAttribute, | 156 const LinkRelAttribute& relAttribute, |
| 157 const KURL& href, | 157 const KURL& href, |
| 158 Document& document, | 158 Document& document, |
| 159 const CrossOriginAttributeValue crossOrigin, | 159 const CrossOriginAttributeValue crossOrigin, |
| 160 const NetworkHintsInterface& networkHintsInterface, | 160 const NetworkHintsInterface& networkHintsInterface, |
| 161 LinkCaller caller) { | 161 LinkCaller caller) { |
| 162 if (relAttribute.isPreconnect() && href.isValid() && | 162 if (relAttribute.isPreconnect() && href.isValid() && |
| 163 href.protocolIsInHTTPFamily()) { | 163 href.protocolIsInHTTPFamily()) { |
| 164 UseCounter::count(document, UseCounter::LinkRelPreconnect); | 164 UseCounter::count(document, UseCounter::LinkRelPreconnect); |
| 165 if (caller == LinkCalledFromHeader) | 165 if (caller == LinkCalledFromHeader) |
| 166 UseCounter::count(document, UseCounter::LinkHeaderPreconnect); | 166 UseCounter::count(document, UseCounter::LinkHeaderPreconnect); |
| 167 Settings* settings = document.settings(); | 167 Settings* settings = document.settings(); |
| 168 if (settings && settings->logDnsPrefetchAndPreconnect()) { | 168 if (settings && settings->getLogDnsPrefetchAndPreconnect()) { |
| 169 document.addConsoleMessage(ConsoleMessage::create( | 169 document.addConsoleMessage(ConsoleMessage::create( |
| 170 OtherMessageSource, DebugMessageLevel, | 170 OtherMessageSource, DebugMessageLevel, |
| 171 String("Preconnect triggered for ") + href.getString())); | 171 String("Preconnect triggered for ") + href.getString())); |
| 172 if (crossOrigin != CrossOriginAttributeNotSet) { | 172 if (crossOrigin != CrossOriginAttributeNotSet) { |
| 173 document.addConsoleMessage(ConsoleMessage::create( | 173 document.addConsoleMessage(ConsoleMessage::create( |
| 174 OtherMessageSource, DebugMessageLevel, | 174 OtherMessageSource, DebugMessageLevel, |
| 175 String("Preconnect CORS setting is ") + | 175 String("Preconnect CORS setting is ") + |
| 176 String((crossOrigin == CrossOriginAttributeAnonymous) | 176 String((crossOrigin == CrossOriginAttributeAnonymous) |
| 177 ? "anonymous" | 177 ? "anonymous" |
| 178 : "use-credentials"))); | 178 : "use-credentials"))); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 325 } |
| 326 | 326 |
| 327 FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link, | 327 FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link, |
| 328 document.encodingName()); | 328 document.encodingName()); |
| 329 | 329 |
| 330 if (crossOrigin != CrossOriginAttributeNotSet) { | 330 if (crossOrigin != CrossOriginAttributeNotSet) { |
| 331 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin(), | 331 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin(), |
| 332 crossOrigin); | 332 crossOrigin); |
| 333 } | 333 } |
| 334 Settings* settings = document.settings(); | 334 Settings* settings = document.settings(); |
| 335 if (settings && settings->logPreload()) { | 335 if (settings && settings->getLogPreload()) { |
| 336 document.addConsoleMessage(ConsoleMessage::create( | 336 document.addConsoleMessage(ConsoleMessage::create( |
| 337 OtherMessageSource, DebugMessageLevel, | 337 OtherMessageSource, DebugMessageLevel, |
| 338 String("Preload triggered for " + href.host() + href.path()))); | 338 String("Preload triggered for " + href.host() + href.path()))); |
| 339 } | 339 } |
| 340 linkRequest.setForPreload(true, monotonicallyIncreasingTime()); | 340 linkRequest.setForPreload(true, monotonicallyIncreasingTime()); |
| 341 linkRequest.setLinkPreload(true); | 341 linkRequest.setLinkPreload(true); |
| 342 return document.loader()->startPreload(resourceType, linkRequest); | 342 return document.loader()->startPreload(resourceType, linkRequest); |
| 343 } | 343 } |
| 344 | 344 |
| 345 static Resource* prefetchIfNeeded(Document& document, | 345 static Resource* prefetchIfNeeded(Document& document, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 487 |
| 488 DEFINE_TRACE(LinkLoader) { | 488 DEFINE_TRACE(LinkLoader) { |
| 489 visitor->trace(m_client); | 489 visitor->trace(m_client); |
| 490 visitor->trace(m_prerender); | 490 visitor->trace(m_prerender); |
| 491 visitor->trace(m_linkPreloadResourceClient); | 491 visitor->trace(m_linkPreloadResourceClient); |
| 492 ResourceOwner<Resource, ResourceClient>::trace(visitor); | 492 ResourceOwner<Resource, ResourceClient>::trace(visitor); |
| 493 PrerenderClient::trace(visitor); | 493 PrerenderClient::trace(visitor); |
| 494 } | 494 } |
| 495 | 495 |
| 496 } // namespace blink | 496 } // namespace blink |
| OLD | NEW |