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

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

Issue 1615703002: Removal of rel=preload link elements should stop the download. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 // TODO(yoav): Convert all uses of the CrossOriginAttribute to CrossOriginAt tributeValue. crbug.com/486689 276 // TODO(yoav): Convert all uses of the CrossOriginAttribute to CrossOriginAt tributeValue. crbug.com/486689
277 // FIXME(crbug.com/463266): We're ignoring type here. Maybe we shouldn't. 277 // FIXME(crbug.com/463266): We're ignoring type here. Maybe we shouldn't.
278 dnsPrefetchIfNeeded(relAttribute, href, document, networkHintsInterface, Lin kCalledFromMarkup); 278 dnsPrefetchIfNeeded(relAttribute, href, document, networkHintsInterface, Lin kCalledFromMarkup);
279 279
280 preconnectIfNeeded(relAttribute, href, document, crossOrigin, networkHintsIn terface, LinkCalledFromMarkup); 280 preconnectIfNeeded(relAttribute, href, document, crossOrigin, networkHintsIn terface, LinkCalledFromMarkup);
281 281
282 if (m_client->shouldLoadLink()) 282 if (m_client->shouldLoadLink())
283 createLinkPreloadResourceClient(preloadIfNeeded(relAttribute, href, docu ment, as, LinkCalledFromMarkup)); 283 createLinkPreloadResourceClient(preloadIfNeeded(relAttribute, href, docu ment, as, LinkCalledFromMarkup));
284 284
285 if (href.isEmpty() || !href.isValid())
286 released();
287
285 // FIXME(crbug.com/323096): Should take care of import. 288 // FIXME(crbug.com/323096): Should take care of import.
286 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource()) && h ref.isValid() && document.frame()) { 289 if ((relAttribute.isLinkPrefetch() || relAttribute.isLinkSubresource()) && h ref.isValid() && document.frame()) {
287 if (!m_client->shouldLoadLink()) 290 if (!m_client->shouldLoadLink())
288 return false; 291 return false;
289 Resource::Type type = Resource::LinkPrefetch; 292 Resource::Type type = Resource::LinkPrefetch;
290 if (relAttribute.isLinkSubresource()) { 293 if (relAttribute.isLinkSubresource()) {
291 type = Resource::LinkSubresource; 294 type = Resource::LinkSubresource;
292 UseCounter::count(document, UseCounter::LinkRelSubresource); 295 UseCounter::count(document, UseCounter::LinkRelSubresource);
293 } else { 296 } else {
294 UseCounter::count(document, UseCounter::LinkRelPrefetch); 297 UseCounter::count(document, UseCounter::LinkRelPrefetch);
(...skipping 21 matching lines...) Expand all
316 } 319 }
317 320
318 void LinkLoader::released() 321 void LinkLoader::released()
319 { 322 {
320 // Only prerenders need treatment here; other links either use the Resource interface, or are notionally 323 // Only prerenders need treatment here; other links either use the Resource interface, or are notionally
321 // atomic (dns prefetch). 324 // atomic (dns prefetch).
322 if (m_prerender) { 325 if (m_prerender) {
323 m_prerender->cancel(); 326 m_prerender->cancel();
324 m_prerender.clear(); 327 m_prerender.clear();
325 } 328 }
329 if (m_linkPreloadResourceClient)
330 m_linkPreloadResourceClient->clear();
Nate Chapin 2016/01/21 21:53:17 I had actually meant deleting the LinkPreloadResou
326 } 331 }
327 332
328 DEFINE_TRACE(LinkLoader) 333 DEFINE_TRACE(LinkLoader)
329 { 334 {
330 visitor->trace(m_client); 335 visitor->trace(m_client);
331 visitor->trace(m_prerender); 336 visitor->trace(m_prerender);
332 visitor->trace(m_linkPreloadResourceClient); 337 visitor->trace(m_linkPreloadResourceClient);
333 ResourceOwner<Resource, ResourceClient>::trace(visitor); 338 ResourceOwner<Resource, ResourceClient>::trace(visitor);
334 } 339 }
335 340
336 } 341 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698