| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 270 |
| 271 if (!isSupportedType(resourceType, mimeType)) { | 271 if (!isSupportedType(resourceType, mimeType)) { |
| 272 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, Wa
rningMessageLevel, String("<link rel=preload> has an unsupported `type` value"))
); | 272 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, Wa
rningMessageLevel, String("<link rel=preload> has an unsupported `type` value"))
); |
| 273 return nullptr; | 273 return nullptr; |
| 274 } | 274 } |
| 275 ResourceRequest resourceRequest(document.completeURL(href)); | 275 ResourceRequest resourceRequest(document.completeURL(href)); |
| 276 ResourceFetcher::determineRequestContext(resourceRequest, resourceType, fals
e); | 276 ResourceFetcher::determineRequestContext(resourceRequest, resourceType, fals
e); |
| 277 FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link); | 277 FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link); |
| 278 | 278 |
| 279 linkRequest.setPriority(document.fetcher()->loadPriority(resourceType, linkR
equest)); | 279 linkRequest.setPriority(document.fetcher()->loadPriority(resourceType, linkR
equest)); |
| 280 if (crossOrigin != CrossOriginAttributeNotSet) | 280 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin(), crossO
rigin); |
| 281 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin(), cr
ossOrigin); | |
| 282 Settings* settings = document.settings(); | 281 Settings* settings = document.settings(); |
| 283 if (settings && settings->logPreload()) | 282 if (settings && settings->logPreload()) |
| 284 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, De
bugMessageLevel, String("Preload triggered for " + href.host() + href.path()))); | 283 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, De
bugMessageLevel, String("Preload triggered for " + href.host() + href.path()))); |
| 285 linkRequest.setForPreload(true); | 284 linkRequest.setForPreload(true); |
| 286 linkRequest.setLinkPreload(true); | 285 linkRequest.setLinkPreload(true); |
| 287 return document.loader()->startPreload(resourceType, linkRequest); | 286 return document.loader()->startPreload(resourceType, linkRequest); |
| 288 } | 287 } |
| 289 | 288 |
| 290 bool LinkLoader::loadLinkFromHeader(const String& headerValue, const KURL& baseU
RL, Document* document, const NetworkHintsInterface& networkHintsInterface, CanL
oadResources canLoadResources) | 289 bool LinkLoader::loadLinkFromHeader(const String& headerValue, const KURL& baseU
RL, Document* document, const NetworkHintsInterface& networkHintsInterface, CanL
oadResources canLoadResources) |
| 291 { | 290 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 if (href.isEmpty() || !href.isValid()) | 333 if (href.isEmpty() || !href.isValid()) |
| 335 released(); | 334 released(); |
| 336 | 335 |
| 337 // FIXME(crbug.com/323096): Should take care of import. | 336 // FIXME(crbug.com/323096): Should take care of import. |
| 338 if (relAttribute.isLinkPrefetch() && href.isValid() && document.frame()) { | 337 if (relAttribute.isLinkPrefetch() && href.isValid() && document.frame()) { |
| 339 if (!m_client->shouldLoadLink()) | 338 if (!m_client->shouldLoadLink()) |
| 340 return false; | 339 return false; |
| 341 UseCounter::count(document, UseCounter::LinkRelPrefetch); | 340 UseCounter::count(document, UseCounter::LinkRelPrefetch); |
| 342 | 341 |
| 343 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe
tchInitiatorTypeNames::link); | 342 FetchRequest linkRequest(ResourceRequest(document.completeURL(href)), Fe
tchInitiatorTypeNames::link); |
| 344 if (crossOrigin != CrossOriginAttributeNotSet) | 343 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin(), cr
ossOrigin); |
| 345 linkRequest.setCrossOriginAccessControl(document.getSecurityOrigin()
, crossOrigin); | |
| 346 setResource(LinkFetchResource::fetch(Resource::LinkPrefetch, linkRequest
, document.fetcher())); | 344 setResource(LinkFetchResource::fetch(Resource::LinkPrefetch, linkRequest
, document.fetcher())); |
| 347 } | 345 } |
| 348 | 346 |
| 349 if (const unsigned prerenderRelTypes = prerenderRelTypesFromRelAttribute(rel
Attribute, document)) { | 347 if (const unsigned prerenderRelTypes = prerenderRelTypesFromRelAttribute(rel
Attribute, document)) { |
| 350 if (!m_prerender) { | 348 if (!m_prerender) { |
| 351 m_prerender = PrerenderHandle::create(document, this, href, prerende
rRelTypes); | 349 m_prerender = PrerenderHandle::create(document, this, href, prerende
rRelTypes); |
| 352 } else if (m_prerender->url() != href) { | 350 } else if (m_prerender->url() != href) { |
| 353 m_prerender->cancel(); | 351 m_prerender->cancel(); |
| 354 m_prerender = PrerenderHandle::create(document, this, href, prerende
rRelTypes); | 352 m_prerender = PrerenderHandle::create(document, this, href, prerende
rRelTypes); |
| 355 } | 353 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 375 | 373 |
| 376 DEFINE_TRACE(LinkLoader) | 374 DEFINE_TRACE(LinkLoader) |
| 377 { | 375 { |
| 378 visitor->trace(m_client); | 376 visitor->trace(m_client); |
| 379 visitor->trace(m_prerender); | 377 visitor->trace(m_prerender); |
| 380 visitor->trace(m_linkPreloadResourceClient); | 378 visitor->trace(m_linkPreloadResourceClient); |
| 381 ResourceOwner<Resource, ResourceClient>::trace(visitor); | 379 ResourceOwner<Resource, ResourceClient>::trace(visitor); |
| 382 } | 380 } |
| 383 | 381 |
| 384 } // namespace blink | 382 } // namespace blink |
| OLD | NEW |