| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return nullptr; | 321 return nullptr; |
| 322 } | 322 } |
| 323 ResourceRequest resourceRequest(document.completeURL(href)); | 323 ResourceRequest resourceRequest(document.completeURL(href)); |
| 324 resourceRequest.setRequestContext( | 324 resourceRequest.setRequestContext( |
| 325 ResourceFetcher::determineRequestContext(resourceType.value(), false)); | 325 ResourceFetcher::determineRequestContext(resourceType.value(), false)); |
| 326 | 326 |
| 327 if (referrerPolicy != ReferrerPolicyDefault) { | 327 if (referrerPolicy != ReferrerPolicyDefault) { |
| 328 resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer( | 328 resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer( |
| 329 referrerPolicy, href, document.outgoingReferrer())); | 329 referrerPolicy, href, document.outgoingReferrer())); |
| 330 } | 330 } |
| 331 resourceRequest.setLinkPreload(true); |
| 331 | 332 |
| 332 FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link, | 333 FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link, |
| 333 document.encodingName()); | 334 document.encodingName()); |
| 334 | 335 |
| 335 if (crossOrigin != CrossOriginAttributeNotSet) { | 336 if (crossOrigin != CrossOriginAttributeNotSet) { |
| 336 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin(), | 337 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin(), |
| 337 crossOrigin); | 338 crossOrigin); |
| 338 } | 339 } |
| 339 Settings* settings = document.settings(); | 340 Settings* settings = document.settings(); |
| 340 if (settings && settings->getLogPreload()) { | 341 if (settings && settings->getLogPreload()) { |
| 341 document.addConsoleMessage(ConsoleMessage::create( | 342 document.addConsoleMessage(ConsoleMessage::create( |
| 342 OtherMessageSource, VerboseMessageLevel, | 343 OtherMessageSource, VerboseMessageLevel, |
| 343 String("Preload triggered for " + href.host() + href.path()))); | 344 String("Preload triggered for " + href.host() + href.path()))); |
| 344 } | 345 } |
| 345 linkRequest.setLinkPreload(true); | |
| 346 return document.loader()->startPreload(resourceType.value(), linkRequest); | 346 return document.loader()->startPreload(resourceType.value(), linkRequest); |
| 347 } | 347 } |
| 348 | 348 |
| 349 static Resource* prefetchIfNeeded(Document& document, | 349 static Resource* prefetchIfNeeded(Document& document, |
| 350 const KURL& href, | 350 const KURL& href, |
| 351 const LinkRelAttribute& relAttribute, | 351 const LinkRelAttribute& relAttribute, |
| 352 CrossOriginAttributeValue crossOrigin, | 352 CrossOriginAttributeValue crossOrigin, |
| 353 ReferrerPolicy referrerPolicy) { | 353 ReferrerPolicy referrerPolicy) { |
| 354 if (relAttribute.isLinkPrefetch() && href.isValid() && document.frame()) { | 354 if (relAttribute.isLinkPrefetch() && href.isValid() && document.frame()) { |
| 355 UseCounter::count(document, UseCounter::LinkRelPrefetch); | 355 UseCounter::count(document, UseCounter::LinkRelPrefetch); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 491 |
| 492 DEFINE_TRACE(LinkLoader) { | 492 DEFINE_TRACE(LinkLoader) { |
| 493 visitor->trace(m_client); | 493 visitor->trace(m_client); |
| 494 visitor->trace(m_prerender); | 494 visitor->trace(m_prerender); |
| 495 visitor->trace(m_linkPreloadResourceClient); | 495 visitor->trace(m_linkPreloadResourceClient); |
| 496 ResourceOwner<Resource, ResourceClient>::trace(visitor); | 496 ResourceOwner<Resource, ResourceClient>::trace(visitor); |
| 497 PrerenderClient::trace(visitor); | 497 PrerenderClient::trace(visitor); |
| 498 } | 498 } |
| 499 | 499 |
| 500 } // namespace blink | 500 } // namespace blink |
| OLD | NEW |