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

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: 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 if (request.forPreload()) { 384 if (request.forPreload()) {
385 DEFINE_RESOURCE_HISTOGRAM("Preload."); 385 DEFINE_RESOURCE_HISTOGRAM("Preload.");
386 } else { 386 } else {
387 DEFINE_RESOURCE_HISTOGRAM(""); 387 DEFINE_RESOURCE_HISTOGRAM("");
388 } 388 }
389 389
390 // Aims to count Resource only referenced from MemoryCache (i.e. what 390 // Aims to count Resource only referenced from MemoryCache (i.e. what
391 // would be dead if MemoryCache holds weak references to Resource). 391 // would be dead if MemoryCache holds weak references to Resource).
392 // Currently we check references to Resource from ResourceClient and 392 // Currently we check references to Resource from ResourceClient and
393 // |m_preloads| only, because they are major sources of references. 393 // |m_preloads| only, because they are major sources of references.
394 if (resource && !resource->hasClients() && (!m_preloads || !m_preloads->cont ains(resource))) { 394 if (resource && !resource->hasClientsOrObservers() && (!m_preloads || !m_pre loads->contains(resource))) {
395 DEFINE_RESOURCE_HISTOGRAM("Dead."); 395 DEFINE_RESOURCE_HISTOGRAM("Dead.");
396 } 396 }
397 } 397 }
398 398
399 PassRefPtrWillBeRawPtr<Resource> ResourceFetcher::requestResource(FetchRequest& request, const ResourceFactory& factory, const SubstituteData& substituteData) 399 PassRefPtrWillBeRawPtr<Resource> ResourceFetcher::requestResource(FetchRequest& request, const ResourceFactory& factory, const SubstituteData& substituteData)
400 { 400 {
401 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || facto ry.type() == Resource::Raw || factory.type() == Resource::XSLStyleSheet); 401 ASSERT(request.options().synchronousPolicy == RequestAsynchronously || facto ry.type() == Resource::Raw || factory.type() == Resource::XSLStyleSheet);
402 402
403 context().upgradeInsecureRequest(request); 403 context().upgradeInsecureRequest(request);
404 context().addClientHintsIfNecessary(request); 404 context().addClientHintsIfNecessary(request);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 break; 463 break;
464 } 464 }
465 465
466 if (!resource) 466 if (!resource)
467 return nullptr; 467 return nullptr;
468 if (resource->getType() != factory.type()) { 468 if (resource->getType() != factory.type()) {
469 ASSERT(request.forPreload()); 469 ASSERT(request.forPreload());
470 return nullptr; 470 return nullptr;
471 } 471 }
472 472
473 if (!resource->hasClients()) 473 if (!resource->hasClientsOrObservers())
474 m_deadStatsRecorder.update(policy); 474 m_deadStatsRecorder.update(policy);
475 475
476 if (policy != Use) 476 if (policy != Use)
477 resource->setIdentifier(createUniqueIdentifier()); 477 resource->setIdentifier(createUniqueIdentifier());
478 478
479 if (!request.forPreload() || policy != Use) { 479 if (!request.forPreload() || policy != Use) {
480 ResourceLoadPriority priority = loadPriority(factory.type(), request, Re sourcePriority::NotVisible); 480 ResourceLoadPriority priority = loadPriority(factory.type(), request, Re sourcePriority::NotVisible);
481 // When issuing another request for a resource that is already in-flight make 481 // When issuing another request for a resource that is already in-flight make
482 // sure to not demote the priority of the in-flight request. If the new request 482 // sure to not demote the priority of the in-flight request. If the new request
483 // isn't at the same priority as the in-flight request, only allow promo tions. 483 // isn't at the same priority as the in-flight request, only allow promo tions.
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 return; 1082 return;
1083 1083
1084 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource Priorities"); 1084 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource Priorities");
1085 for (const auto& loader : m_loaders->hashSet()) { 1085 for (const auto& loader : m_loaders->hashSet()) {
1086 ASSERT(loader); 1086 ASSERT(loader);
1087 Resource* resource = loader->cachedResource(); 1087 Resource* resource = loader->cachedResource();
1088 ASSERT(resource); 1088 ASSERT(resource);
1089 if (!resource->isImage()) 1089 if (!resource->isImage())
1090 continue; 1090 continue;
1091 1091
1092 ResourcePriority resourcePriority = resource->priorityFromClients(); 1092 ResourcePriority resourcePriority = resource->priorityFromObservers();
1093 ResourceLoadPriority resourceLoadPriority = loadPriority(Resource::Image , FetchRequest(resource->resourceRequest(), FetchInitiatorInfo()), resourcePrior ity.visibility); 1093 ResourceLoadPriority resourceLoadPriority = loadPriority(Resource::Image , FetchRequest(resource->resourceRequest(), FetchInitiatorInfo()), resourcePrior ity.visibility);
1094 if (resourceLoadPriority == resource->resourceRequest().priority()) 1094 if (resourceLoadPriority == resource->resourceRequest().priority())
1095 continue; 1095 continue;
1096 1096
1097 resource->didChangePriority(resourceLoadPriority, resourcePriority.intra PriorityValue); 1097 resource->didChangePriority(resourceLoadPriority, resourcePriority.intra PriorityValue);
1098 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource, "ChangeP riority", "priority", resourceLoadPriority); 1098 TRACE_EVENT_ASYNC_STEP_INTO1("blink.net", "Resource", resource, "ChangeP riority", "priority", resourceLoadPriority);
1099 context().dispatchDidChangeResourcePriority(resource->identifier(), reso urceLoadPriority, resourcePriority.intraPriorityValue); 1099 context().dispatchDidChangeResourcePriority(resource->identifier(), reso urceLoadPriority, resourcePriority.intraPriorityValue);
1100 } 1100 }
1101 } 1101 }
1102 1102
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 visitor->trace(m_loaders); 1214 visitor->trace(m_loaders);
1215 visitor->trace(m_nonBlockingLoaders); 1215 visitor->trace(m_nonBlockingLoaders);
1216 #if ENABLE(OILPAN) 1216 #if ENABLE(OILPAN)
1217 visitor->trace(m_documentResources); 1217 visitor->trace(m_documentResources);
1218 visitor->trace(m_preloads); 1218 visitor->trace(m_preloads);
1219 visitor->trace(m_resourceTimingInfoMap); 1219 visitor->trace(m_resourceTimingInfoMap);
1220 #endif 1220 #endif
1221 } 1221 }
1222 1222
1223 } // namespace blink 1223 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceClientWalker.h ('k') | third_party/WebKit/Source/core/fetch/ScriptResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698