| 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 27 matching lines...) Expand all Loading... |
| 38 #include "core/fetch/FetchRequest.h" | 38 #include "core/fetch/FetchRequest.h" |
| 39 #include "core/fetch/LinkFetchResource.h" | 39 #include "core/fetch/LinkFetchResource.h" |
| 40 #include "core/fetch/ResourceFetcher.h" | 40 #include "core/fetch/ResourceFetcher.h" |
| 41 #include "core/frame/Settings.h" | 41 #include "core/frame/Settings.h" |
| 42 #include "core/frame/UseCounter.h" | 42 #include "core/frame/UseCounter.h" |
| 43 #include "core/html/CrossOriginAttribute.h" | 43 #include "core/html/CrossOriginAttribute.h" |
| 44 #include "core/html/LinkRelAttribute.h" | 44 #include "core/html/LinkRelAttribute.h" |
| 45 #include "core/html/parser/HTMLPreloadScanner.h" | 45 #include "core/html/parser/HTMLPreloadScanner.h" |
| 46 #include "core/inspector/ConsoleMessage.h" | 46 #include "core/inspector/ConsoleMessage.h" |
| 47 #include "core/loader/DocumentLoader.h" | 47 #include "core/loader/DocumentLoader.h" |
| 48 #include "core/loader/LinkHeader.h" | |
| 49 #include "core/loader/NetworkHintsInterface.h" | 48 #include "core/loader/NetworkHintsInterface.h" |
| 50 #include "core/loader/PrerenderHandle.h" | 49 #include "core/loader/PrerenderHandle.h" |
| 51 #include "platform/MIMETypeRegistry.h" | 50 #include "platform/MIMETypeRegistry.h" |
| 52 #include "platform/Prerender.h" | 51 #include "platform/Prerender.h" |
| 53 #include "platform/RuntimeEnabledFeatures.h" | 52 #include "platform/RuntimeEnabledFeatures.h" |
| 53 #include "platform/network/LinkHeader.h" |
| 54 #include "platform/network/NetworkHints.h" | 54 #include "platform/network/NetworkHints.h" |
| 55 #include "public/platform/WebPrerender.h" | 55 #include "public/platform/WebPrerender.h" |
| 56 | 56 |
| 57 namespace blink { | 57 namespace blink { |
| 58 | 58 |
| 59 static unsigned prerenderRelTypesFromRelAttribute(const LinkRelAttribute& relAtt
ribute, Document& document) | 59 static unsigned prerenderRelTypesFromRelAttribute(const LinkRelAttribute& relAtt
ribute, Document& document) |
| 60 { | 60 { |
| 61 unsigned result = 0; | 61 unsigned result = 0; |
| 62 if (relAttribute.isLinkPrerender()) { | 62 if (relAttribute.isLinkPrerender()) { |
| 63 result |= PrerenderRelTypePrerender; | 63 result |= PrerenderRelTypePrerender; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 LinkRelAttribute relAttribute(header.rel()); | 314 LinkRelAttribute relAttribute(header.rel()); |
| 315 KURL url(baseURL, header.url()); | 315 KURL url(baseURL, header.url()); |
| 316 if (canLoadResources != OnlyLoadResources) { | 316 if (canLoadResources != OnlyLoadResources) { |
| 317 if (RuntimeEnabledFeatures::linkHeaderEnabled()) | 317 if (RuntimeEnabledFeatures::linkHeaderEnabled()) |
| 318 dnsPrefetchIfNeeded(relAttribute, url, *document, networkHintsIn
terface, LinkCalledFromHeader); | 318 dnsPrefetchIfNeeded(relAttribute, url, *document, networkHintsIn
terface, LinkCalledFromHeader); |
| 319 | 319 |
| 320 if (RuntimeEnabledFeatures::linkPreconnectEnabled()) | 320 if (RuntimeEnabledFeatures::linkPreconnectEnabled()) |
| 321 preconnectIfNeeded(relAttribute, url, *document, header.crossOri
gin(), networkHintsInterface, LinkCalledFromHeader); | 321 preconnectIfNeeded(relAttribute, url, *document, crossOriginAttr
ibuteValue(header.crossOrigin()), networkHintsInterface, LinkCalledFromHeader); |
| 322 } | 322 } |
| 323 if (canLoadResources != DoNotLoadResources) { | 323 if (canLoadResources != DoNotLoadResources) { |
| 324 bool errorOccurred = false; | 324 bool errorOccurred = false; |
| 325 if (RuntimeEnabledFeatures::linkPreloadEnabled()) { | 325 if (RuntimeEnabledFeatures::linkPreloadEnabled()) { |
| 326 ViewportDescription* viewportDescription = (viewportDescriptionW
rapper && viewportDescriptionWrapper->set) ? &(viewportDescriptionWrapper->descr
iption) : nullptr; | 326 ViewportDescription* viewportDescription = (viewportDescriptionW
rapper && viewportDescriptionWrapper->set) ? &(viewportDescriptionWrapper->descr
iption) : nullptr; |
| 327 preloadIfNeeded(relAttribute, url, *document, header.as(), heade
r.mimeType(), header.media(), header.crossOrigin(), LinkCalledFromHeader, errorO
ccurred, viewportDescription); | 327 preloadIfNeeded(relAttribute, url, *document, header.as(), heade
r.mimeType(), header.media(), crossOriginAttributeValue(header.crossOrigin()), L
inkCalledFromHeader, errorOccurred, viewportDescription); |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 // TODO(yoav): Add more supported headers as needed. | 330 // TODO(yoav): Add more supported headers as needed. |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, CrossOriginAttri
buteValue crossOrigin, const String& type, | 334 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, CrossOriginAttri
buteValue crossOrigin, const String& type, |
| 335 const String& as, const String& media, const KURL& href, Document& document,
const NetworkHintsInterface& networkHintsInterface) | 335 const String& as, const String& media, const KURL& href, Document& document,
const NetworkHintsInterface& networkHintsInterface) |
| 336 { | 336 { |
| 337 // TODO(yoav): Do all links need to load only after they're in document??? | 337 // TODO(yoav): Do all links need to load only after they're in document??? |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 DEFINE_TRACE(LinkLoader) | 393 DEFINE_TRACE(LinkLoader) |
| 394 { | 394 { |
| 395 visitor->trace(m_client); | 395 visitor->trace(m_client); |
| 396 visitor->trace(m_prerender); | 396 visitor->trace(m_prerender); |
| 397 visitor->trace(m_linkPreloadResourceClient); | 397 visitor->trace(m_linkPreloadResourceClient); |
| 398 ResourceOwner<Resource, ResourceClient>::trace(visitor); | 398 ResourceOwner<Resource, ResourceClient>::trace(visitor); |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace blink | 401 } // namespace blink |
| OLD | NEW |