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

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

Issue 2194473002: Remove LinkPreload runtime flag (status=stable) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return false; 248 return false;
249 } 249 }
250 250
251 static Resource* preloadIfNeeded(const LinkRelAttribute& relAttribute, const KUR L& href, Document& document, const String& as, const String& mimeType, 251 static Resource* preloadIfNeeded(const LinkRelAttribute& relAttribute, const KUR L& href, Document& document, const String& as, const String& mimeType,
252 const String& media, CrossOriginAttributeValue crossOrigin, LinkCaller calle r, bool& errorOccurred, ViewportDescription* viewportDescription) 252 const String& media, CrossOriginAttributeValue crossOrigin, LinkCaller calle r, bool& errorOccurred, ViewportDescription* viewportDescription)
253 { 253 {
254 if (!document.loader() || !relAttribute.isLinkPreload()) 254 if (!document.loader() || !relAttribute.isLinkPreload())
255 return nullptr; 255 return nullptr;
256 256
257 UseCounter::count(document, UseCounter::LinkRelPreload); 257 UseCounter::count(document, UseCounter::LinkRelPreload);
258 ASSERT(RuntimeEnabledFeatures::linkPreloadEnabled());
259 if (!href.isValid() || href.isEmpty()) { 258 if (!href.isValid() || href.isEmpty()) {
260 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, Wa rningMessageLevel, String("<link rel=preload> has an invalid `href` value"))); 259 document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, Wa rningMessageLevel, String("<link rel=preload> has an invalid `href` value")));
261 return nullptr; 260 return nullptr;
262 } 261 }
263 262
264 if (!media.isEmpty()) { 263 if (!media.isEmpty()) {
265 MediaValues* mediaValues = MediaValues::createDynamicIfFrameExists(docum ent.frame()); 264 MediaValues* mediaValues = MediaValues::createDynamicIfFrameExists(docum ent.frame());
266 if (viewportDescription) 265 if (viewportDescription)
267 mediaValues->overrideViewportDimensions(viewportDescription->maxWidt h.getFloatValue(), viewportDescription->maxHeight.getFloatValue()); 266 mediaValues->overrideViewportDimensions(viewportDescription->maxWidt h.getFloatValue(), viewportDescription->maxHeight.getFloatValue());
268 267
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // Sanity check to avoid re-entrancy here. 320 // Sanity check to avoid re-entrancy here.
322 if (url == baseURL) 321 if (url == baseURL)
323 continue; 322 continue;
324 if (canLoadResources != OnlyLoadResources) { 323 if (canLoadResources != OnlyLoadResources) {
325 dnsPrefetchIfNeeded(relAttribute, url, *document, networkHintsInterf ace, LinkCalledFromHeader); 324 dnsPrefetchIfNeeded(relAttribute, url, *document, networkHintsInterf ace, LinkCalledFromHeader);
326 325
327 preconnectIfNeeded(relAttribute, url, *document, crossOriginAttribut eValue(header.crossOrigin()), networkHintsInterface, LinkCalledFromHeader); 326 preconnectIfNeeded(relAttribute, url, *document, crossOriginAttribut eValue(header.crossOrigin()), networkHintsInterface, LinkCalledFromHeader);
328 } 327 }
329 if (canLoadResources != DoNotLoadResources) { 328 if (canLoadResources != DoNotLoadResources) {
330 bool errorOccurred = false; 329 bool errorOccurred = false;
331 if (RuntimeEnabledFeatures::linkPreloadEnabled()) { 330 ViewportDescription* viewportDescription = (viewportDescriptionWrapp er && viewportDescriptionWrapper->set) ? &(viewportDescriptionWrapper->descripti on) : nullptr;
332 ViewportDescription* viewportDescription = (viewportDescriptionW rapper && viewportDescriptionWrapper->set) ? &(viewportDescriptionWrapper->descr iption) : nullptr; 331 preloadIfNeeded(relAttribute, url, *document, header.as(), header.mi meType(), header.media(), crossOriginAttributeValue(header.crossOrigin()), LinkC alledFromHeader, errorOccurred, viewportDescription);
333 preloadIfNeeded(relAttribute, url, *document, header.as(), heade r.mimeType(), header.media(), crossOriginAttributeValue(header.crossOrigin()), L inkCalledFromHeader, errorOccurred, viewportDescription);
334 }
335 } 332 }
336 // TODO(yoav): Add more supported headers as needed. 333 // TODO(yoav): Add more supported headers as needed.
337 } 334 }
338 } 335 }
339 336
340 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, CrossOriginAttri buteValue crossOrigin, const String& type, 337 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, CrossOriginAttri buteValue crossOrigin, const String& type,
341 const String& as, const String& media, const KURL& href, Document& document, const NetworkHintsInterface& networkHintsInterface) 338 const String& as, const String& media, const KURL& href, Document& document, const NetworkHintsInterface& networkHintsInterface)
342 { 339 {
343 // TODO(yoav): Do all links need to load only after they're in document??? 340 // TODO(yoav): Do all links need to load only after they're in document???
344 341
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 DEFINE_TRACE(LinkLoader) 396 DEFINE_TRACE(LinkLoader)
400 { 397 {
401 visitor->trace(m_client); 398 visitor->trace(m_client);
402 visitor->trace(m_prerender); 399 visitor->trace(m_prerender);
403 visitor->trace(m_linkPreloadResourceClient); 400 visitor->trace(m_linkPreloadResourceClient);
404 ResourceOwner<Resource, ResourceClient>::trace(visitor); 401 ResourceOwner<Resource, ResourceClient>::trace(visitor);
405 PrerenderClient::trace(visitor); 402 PrerenderClient::trace(visitor);
406 } 403 }
407 404
408 } // namespace blink 405 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/LinkRelAttribute.cpp ('k') | third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698