Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: third_party/WebKit/Source/core/loader/LinkLoader.cpp

Issue 1729963002: WIP/proof-of-concept to make blink::LinkHeader reuse net:: parsing code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string-tokenizer-brackets
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 24 matching lines...) Expand all
35 #include "core/fetch/FetchInitiatorTypeNames.h" 35 #include "core/fetch/FetchInitiatorTypeNames.h"
36 #include "core/fetch/FetchRequest.h" 36 #include "core/fetch/FetchRequest.h"
37 #include "core/fetch/LinkFetchResource.h" 37 #include "core/fetch/LinkFetchResource.h"
38 #include "core/fetch/ResourceFetcher.h" 38 #include "core/fetch/ResourceFetcher.h"
39 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
40 #include "core/frame/UseCounter.h" 40 #include "core/frame/UseCounter.h"
41 #include "core/html/CrossOriginAttribute.h" 41 #include "core/html/CrossOriginAttribute.h"
42 #include "core/html/LinkRelAttribute.h" 42 #include "core/html/LinkRelAttribute.h"
43 #include "core/inspector/ConsoleMessage.h" 43 #include "core/inspector/ConsoleMessage.h"
44 #include "core/loader/DocumentLoader.h" 44 #include "core/loader/DocumentLoader.h"
45 #include "core/loader/LinkHeader.h"
46 #include "core/loader/NetworkHintsInterface.h" 45 #include "core/loader/NetworkHintsInterface.h"
47 #include "core/loader/PrerenderHandle.h" 46 #include "core/loader/PrerenderHandle.h"
48 #include "platform/Prerender.h" 47 #include "platform/Prerender.h"
49 #include "platform/RuntimeEnabledFeatures.h" 48 #include "platform/RuntimeEnabledFeatures.h"
49 #include "platform/network/LinkHeader.h"
50 #include "platform/network/NetworkHints.h" 50 #include "platform/network/NetworkHints.h"
51 #include "public/platform/WebPrerender.h" 51 #include "public/platform/WebPrerender.h"
52 52
53 namespace blink { 53 namespace blink {
54 54
55 static unsigned prerenderRelTypesFromRelAttribute(const LinkRelAttribute& relAtt ribute, Document& document) 55 static unsigned prerenderRelTypesFromRelAttribute(const LinkRelAttribute& relAtt ribute, Document& document)
56 { 56 {
57 unsigned result = 0; 57 unsigned result = 0;
58 if (relAttribute.isLinkPrerender()) { 58 if (relAttribute.isLinkPrerender()) {
59 result |= PrerenderRelTypePrerender; 59 result |= PrerenderRelTypePrerender;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty()) 253 if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty())
254 return false; 254 return false;
255 255
256 LinkRelAttribute relAttribute(header.rel()); 256 LinkRelAttribute relAttribute(header.rel());
257 KURL url(baseURL, header.url()); 257 KURL url(baseURL, header.url());
258 if (canLoadResources != OnlyLoadResources) { 258 if (canLoadResources != OnlyLoadResources) {
259 if (RuntimeEnabledFeatures::linkHeaderEnabled()) 259 if (RuntimeEnabledFeatures::linkHeaderEnabled())
260 dnsPrefetchIfNeeded(relAttribute, url, *document, networkHintsIn terface, LinkCalledFromHeader); 260 dnsPrefetchIfNeeded(relAttribute, url, *document, networkHintsIn terface, LinkCalledFromHeader);
261 261
262 if (RuntimeEnabledFeatures::linkPreconnectEnabled()) 262 if (RuntimeEnabledFeatures::linkPreconnectEnabled())
263 preconnectIfNeeded(relAttribute, url, *document, header.crossOri gin(), networkHintsInterface, LinkCalledFromHeader); 263 preconnectIfNeeded(relAttribute, url, *document, crossOriginAttr ibuteValue(header.crossOrigin()), networkHintsInterface, LinkCalledFromHeader);
264 } 264 }
265 if (canLoadResources != DoNotLoadResources) { 265 if (canLoadResources != DoNotLoadResources) {
266 if (RuntimeEnabledFeatures::linkPreloadEnabled()) 266 if (RuntimeEnabledFeatures::linkPreloadEnabled())
267 preloadIfNeeded(relAttribute, url, *document, header.as(), heade r.crossOrigin(), LinkCalledFromHeader); 267 preloadIfNeeded(relAttribute, url, *document, header.as(), cross OriginAttributeValue(header.crossOrigin()), LinkCalledFromHeader);
268 } 268 }
269 // TODO(yoav): Add more supported headers as needed. 269 // TODO(yoav): Add more supported headers as needed.
270 } 270 }
271 return true; 271 return true;
272 } 272 }
273 273
274 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, CrossOriginAttri buteValue crossOrigin, const String& type, const String& as, const KURL& href, D ocument& document, const NetworkHintsInterface& networkHintsInterface) 274 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, CrossOriginAttri buteValue crossOrigin, const String& type, const String& as, const KURL& href, D ocument& document, const NetworkHintsInterface& networkHintsInterface)
275 { 275 {
276 // TODO(yoav): Do all links need to load only after they're in document??? 276 // TODO(yoav): Do all links need to load only after they're in document???
277 277
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 DEFINE_TRACE(LinkLoader) 329 DEFINE_TRACE(LinkLoader)
330 { 330 {
331 visitor->trace(m_client); 331 visitor->trace(m_client);
332 visitor->trace(m_prerender); 332 visitor->trace(m_prerender);
333 visitor->trace(m_linkPreloadResourceClient); 333 visitor->trace(m_linkPreloadResourceClient);
334 ResourceOwner<Resource, ResourceClient>::trace(visitor); 334 ResourceOwner<Resource, ResourceClient>::trace(visitor);
335 } 335 }
336 336
337 } // namespace blink 337 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/LinkHeaderTest.cpp ('k') | third_party/WebKit/Source/platform/blink_platform.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698