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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 Settings* settings = document.settings(); | 295 Settings* settings = document.settings(); |
296 if (settings && settings->logPreload()) | 296 if (settings && settings->logPreload()) |
297 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, De
bugMessageLevel, String("Preload triggered for " + href.host() + href.path()))); | 297 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, De
bugMessageLevel, String("Preload triggered for " + href.host() + href.path()))); |
298 linkRequest.setForPreload(true, monotonicallyIncreasingTime()); | 298 linkRequest.setForPreload(true, monotonicallyIncreasingTime()); |
299 linkRequest.setLinkPreload(true); | 299 linkRequest.setLinkPreload(true); |
300 linkRequest.setPriority(document.fetcher()->loadPriority(resourceType, linkR
equest)); | 300 linkRequest.setPriority(document.fetcher()->loadPriority(resourceType, linkR
equest)); |
301 return document.loader()->startPreload(resourceType, linkRequest); | 301 return document.loader()->startPreload(resourceType, linkRequest); |
302 } | 302 } |
303 | 303 |
304 void LinkLoader::loadLinksFromHeader(const String& headerValue, const KURL& base
URL, Document* document, const NetworkHintsInterface& networkHintsInterface, | 304 void LinkLoader::loadLinksFromHeader(const String& headerValue, const KURL& base
URL, Document* document, const NetworkHintsInterface& networkHintsInterface, |
305 CanLoadResources canLoadResources, ViewportDescriptionWrapper* viewportDescr
iptionWrapper) | 305 CanLoadResources canLoadResources, MediaPreloadPolicy mediaPolicy, ViewportD
escriptionWrapper* viewportDescriptionWrapper) |
306 { | 306 { |
307 if (!document || headerValue.isEmpty()) | 307 if (!document || headerValue.isEmpty()) |
308 return; | 308 return; |
309 LinkHeaderSet headerSet(headerValue); | 309 LinkHeaderSet headerSet(headerValue); |
310 for (auto& header : headerSet) { | 310 for (auto& header : headerSet) { |
311 if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty()) | 311 if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty()) |
312 continue; | 312 continue; |
313 | 313 |
| 314 if (mediaPolicy == OnlyLoadMedia && header.media().isEmpty()) |
| 315 continue; |
| 316 if (mediaPolicy == OnlyLoadNonMedia && !header.media().isEmpty()) |
| 317 continue; |
| 318 |
314 LinkRelAttribute relAttribute(header.rel()); | 319 LinkRelAttribute relAttribute(header.rel()); |
315 KURL url(baseURL, header.url()); | 320 KURL url(baseURL, header.url()); |
316 // Sanity check to avoid re-entrancy here. | 321 // Sanity check to avoid re-entrancy here. |
317 if (url == baseURL) | 322 if (url == baseURL) |
318 continue; | 323 continue; |
319 if (canLoadResources != OnlyLoadResources) { | 324 if (canLoadResources != OnlyLoadResources) { |
320 if (RuntimeEnabledFeatures::linkHeaderEnabled()) | 325 if (RuntimeEnabledFeatures::linkHeaderEnabled()) |
321 dnsPrefetchIfNeeded(relAttribute, url, *document, networkHintsIn
terface, LinkCalledFromHeader); | 326 dnsPrefetchIfNeeded(relAttribute, url, *document, networkHintsIn
terface, LinkCalledFromHeader); |
322 | 327 |
323 if (RuntimeEnabledFeatures::linkPreconnectEnabled()) | 328 if (RuntimeEnabledFeatures::linkPreconnectEnabled()) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 DEFINE_TRACE(LinkLoader) | 401 DEFINE_TRACE(LinkLoader) |
397 { | 402 { |
398 visitor->trace(m_client); | 403 visitor->trace(m_client); |
399 visitor->trace(m_prerender); | 404 visitor->trace(m_prerender); |
400 visitor->trace(m_linkPreloadResourceClient); | 405 visitor->trace(m_linkPreloadResourceClient); |
401 ResourceOwner<Resource, ResourceClient>::trace(visitor); | 406 ResourceOwner<Resource, ResourceClient>::trace(visitor); |
402 PrerenderClient::trace(visitor); | 407 PrerenderClient::trace(visitor); |
403 } | 408 } |
404 | 409 |
405 } // namespace blink | 410 } // namespace blink |
OLD | NEW |