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