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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp

Issue 1706083002: Split ImageResourceClient into ResourceClient and ImageResourceObserver [1/2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reflect comments and Rebase Created 4 years, 9 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) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 if (request.forPreload()) { 373 if (request.forPreload()) {
374 DEFINE_RESOURCE_HISTOGRAM("Preload."); 374 DEFINE_RESOURCE_HISTOGRAM("Preload.");
375 } else { 375 } else {
376 DEFINE_RESOURCE_HISTOGRAM(""); 376 DEFINE_RESOURCE_HISTOGRAM("");
377 } 377 }
378 378
379 // Aims to count Resource only referenced from MemoryCache (i.e. what 379 // Aims to count Resource only referenced from MemoryCache (i.e. what
380 // would be dead if MemoryCache holds weak references to Resource). 380 // would be dead if MemoryCache holds weak references to Resource).
381 // Currently we check references to Resource from ResourceClient and 381 // Currently we check references to Resource from ResourceClient and
382 // |m_preloads| only, because they are major sources of references. 382 // |m_preloads| only, because they are major sources of references.
383 if (resource && !resource->hasClients() && (!m_preloads || !m_preloads->cont ains(resource))) { 383 if (resource && !resource->hasClientsOrObservers() && (!m_preloads || !m_pre loads->contains(resource))) {
384 DEFINE_RESOURCE_HISTOGRAM("Dead."); 384 DEFINE_RESOURCE_HISTOGRAM("Dead.");
385 } 385 }
386 } 386 }
387 387
388 PassRefPtrWillBeRawPtr<Resource> ResourceFetcher::requestResource(FetchRequest& request, const ResourceFactory& factory, const SubstituteData& substituteData) 388 PassRefPtrWillBeRawPtr<Resource> ResourceFetcher::requestResource(FetchRequest& request, const ResourceFactory& factory, const SubstituteData& substituteData)
389 { 389 {
390 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || facto ry.type() == Resource::Raw || factory.type() == Resource::XSLStyleSheet); 390 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || facto ry.type() == Resource::Raw || factory.type() == Resource::XSLStyleSheet);
391 391
392 context().upgradeInsecureRequest(request); 392 context().upgradeInsecureRequest(request);
393 context().addClientHintsIfNecessary(request); 393 context().addClientHintsIfNecessary(request);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 break; 452 break;
453 } 453 }
454 454
455 if (!resource) 455 if (!resource)
456 return nullptr; 456 return nullptr;
457 if (resource->getType() != factory.type()) { 457 if (resource->getType() != factory.type()) {
458 ASSERT(request.forPreload()); 458 ASSERT(request.forPreload());
459 return nullptr; 459 return nullptr;
460 } 460 }
461 461
462 if (!resource->hasClients()) 462 if (!resource->hasClientsOrObservers())
463 m_deadStatsRecorder.update(policy); 463 m_deadStatsRecorder.update(policy);
464 464
465 if (policy != Use) 465 if (policy != Use)
466 resource->setIdentifier(createUniqueIdentifier()); 466 resource->setIdentifier(createUniqueIdentifier());
467 467
468 if (!request.forPreload() || policy != Use) { 468 if (!request.forPreload() || policy != Use) {
469 ResourceLoadPriority priority = loadPriority(factory.type(), request, Re sourcePriority::NotVisible); 469 ResourceLoadPriority priority = loadPriority(factory.type(), request, Re sourcePriority::NotVisible);
470 // When issuing another request for a resource that is already in-flight make 470 // When issuing another request for a resource that is already in-flight make
471 // sure to not demote the priority of the in-flight request. If the new request 471 // sure to not demote the priority of the in-flight request. If the new request
472 // isn't at the same priority as the in-flight request, only allow promo tions. 472 // isn't at the same priority as the in-flight request, only allow promo tions.
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 return; 1087 return;
1088 1088
1089 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource Priorities"); 1089 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource Priorities");
1090 for (const auto& loader : m_loaders->hashSet()) { 1090 for (const auto& loader : m_loaders->hashSet()) {
1091 ASSERT(loader); 1091 ASSERT(loader);
1092 Resource* resource = loader->cachedResource(); 1092 Resource* resource = loader->cachedResource();
1093 ASSERT(resource); 1093 ASSERT(resource);
1094 if (!resource->isImage()) 1094 if (!resource->isImage())
1095 continue; 1095 continue;
1096 1096
1097 ResourcePriority resourcePriority = resource->priorityFromClients(); 1097 ResourcePriority resourcePriority = resource->priorityFromObservers();
1098 ResourceLoadPriority resourceLoadPriority = loadPriority(Resource::Image , FetchRequest(resource->resourceRequest(), FetchInitiatorInfo()), resourcePrior ity.visibility); 1098 ResourceLoadPriority resourceLoadPriority = loadPriority(Resource::Image , FetchRequest(resource->resourceRequest(), FetchInitiatorInfo()), resourcePrior ity.visibility);
1099 if (resourceLoadPriority == resource->resourceRequest().priority()) 1099 if (resourceLoadPriority == resource->resourceRequest().priority())
1100 continue; 1100 continue;
1101 1101
1102 resource->didChangePriority(resourceLoadPriority, resourcePriority.intra PriorityValue); 1102 resource->didChangePriority(resourceLoadPriority, resourcePriority.intra PriorityValue);
1103 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource, "ChangeP riority", "priority", resourceLoadPriority); 1103 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource, "ChangeP riority", "priority", resourceLoadPriority);
1104 context().dispatchDidChangeResourcePriority(resource->identifier(), reso urceLoadPriority, resourcePriority.intraPriorityValue); 1104 context().dispatchDidChangeResourcePriority(resource->identifier(), reso urceLoadPriority, resourcePriority.intraPriorityValue);
1105 } 1105 }
1106 } 1106 }
1107 1107
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 visitor->trace(m_loaders); 1219 visitor->trace(m_loaders);
1220 visitor->trace(m_nonBlockingLoaders); 1220 visitor->trace(m_nonBlockingLoaders);
1221 #if ENABLE(OILPAN) 1221 #if ENABLE(OILPAN)
1222 visitor->trace(m_documentResources); 1222 visitor->trace(m_documentResources);
1223 visitor->trace(m_preloads); 1223 visitor->trace(m_preloads);
1224 visitor->trace(m_resourceTimingInfoMap); 1224 visitor->trace(m_resourceTimingInfoMap);
1225 #endif 1225 #endif
1226 } 1226 }
1227 1227
1228 } // namespace blink 1228 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698