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

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

Issue 2527353002: Phase II Step 3: Reload LoFi/placeholder images via new ImageResource
Patch Set: Use startLoad() again to avoid re-applying modifications to ResourceRequest on reload Created 3 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 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 rights reserved. 6 rights reserved.
7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 ? FetchContext::V8ActivityLoggingPolicy::SuppressLogging 506 ? FetchContext::V8ActivityLoggingPolicy::SuppressLogging
507 : FetchContext::V8ActivityLoggingPolicy::Log)); 507 : FetchContext::V8ActivityLoggingPolicy::Log));
508 if (!request.url().isValid()) 508 if (!request.url().isValid())
509 return Abort; 509 return Abort;
510 510
511 resourceRequest.setAllowStoredCredentials( 511 resourceRequest.setAllowStoredCredentials(
512 request.options().allowCredentials == AllowStoredCredentials); 512 request.options().allowCredentials == AllowStoredCredentials);
513 return Continue; 513 return Continue;
514 } 514 }
515 515
516 void ResourceFetcher::addToDocumentResources(Resource* resource) {
517 m_documentResources.set(
518 MemoryCache::removeFragmentIdentifierIfNeeded(resource->url()), resource);
519 }
520
516 Resource* ResourceFetcher::requestResource( 521 Resource* ResourceFetcher::requestResource(
517 FetchRequest& request, 522 FetchRequest& request,
518 const ResourceFactory& factory, 523 const ResourceFactory& factory,
519 const SubstituteData& substituteData) { 524 const SubstituteData& substituteData) {
520 unsigned long identifier = createUniqueIdentifier(); 525 unsigned long identifier = createUniqueIdentifier();
521 ResourceRequest& resourceRequest = request.mutableResourceRequest(); 526 ResourceRequest& resourceRequest = request.mutableResourceRequest();
522 network_instrumentation::ScopedResourceLoadTracker scopedResourceLoadTracker( 527 network_instrumentation::ScopedResourceLoadTracker scopedResourceLoadTracker(
523 identifier, resourceRequest); 528 identifier, resourceRequest);
524 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Fetch.RequestResourceTime"); 529 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Fetch.RequestResourceTime");
525 // TODO(dproy): Remove this. http://crbug.com/659666 530 // TODO(dproy): Remove this. http://crbug.com/659666
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 // TODO(yoav): I'd expect the stated scenario to not go here, as its policy 610 // TODO(yoav): I'd expect the stated scenario to not go here, as its policy
606 // would be Use. 611 // would be Use.
607 } 612 }
608 613
609 // If only the fragment identifiers differ, it is the same resource. 614 // If only the fragment identifiers differ, it is the same resource.
610 DCHECK(equalIgnoringFragmentIdentifier(resource->url(), request.url())); 615 DCHECK(equalIgnoringFragmentIdentifier(resource->url(), request.url()));
611 requestLoadStarted( 616 requestLoadStarted(
612 identifier, resource, request, 617 identifier, resource, request,
613 policy == Use ? ResourceLoadingFromCache : ResourceLoadingFromNetwork, 618 policy == Use ? ResourceLoadingFromCache : ResourceLoadingFromNetwork,
614 isStaticData); 619 isStaticData);
615 m_documentResources.set( 620 addToDocumentResources(resource);
616 MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), resource);
617 621
618 // Returns with an existing resource if the resource does not need to start 622 // Returns with an existing resource if the resource does not need to start
619 // loading immediately. If revalidation policy was determined as |Revalidate|, 623 // loading immediately. If revalidation policy was determined as |Revalidate|,
620 // the resource was already initialized for the revalidation here, but won't 624 // the resource was already initialized for the revalidation here, but won't
621 // start loading. 625 // start loading.
622 if (!resourceNeedsLoad(resource, request, policy)) 626 if (!resourceNeedsLoad(resource, request, policy))
623 return resource; 627 return resource;
624 628
625 if (!startLoad(resource)) 629 if (!startLoad(resource))
626 return nullptr; 630 return nullptr;
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 resourcePriority.intraPriorityValue); 1329 resourcePriority.intraPriorityValue);
1326 network_instrumentation::resourcePrioritySet(resource->identifier(), 1330 network_instrumentation::resourcePrioritySet(resource->identifier(),
1327 resourceLoadPriority); 1331 resourceLoadPriority);
1328 context().dispatchDidChangeResourcePriority( 1332 context().dispatchDidChangeResourcePriority(
1329 resource->identifier(), resourceLoadPriority, 1333 resource->identifier(), resourceLoadPriority,
1330 resourcePriority.intraPriorityValue); 1334 resourcePriority.intraPriorityValue);
1331 } 1335 }
1332 } 1336 }
1333 1337
1334 void ResourceFetcher::reloadLoFiImages() { 1338 void ResourceFetcher::reloadLoFiImages() {
1335 for (const auto& documentResource : m_documentResources) { 1339 for (auto& documentResource : m_documentResources) {
yhirano 2017/03/17 13:09:35 What is the intention of this change?
1336 Resource* resource = documentResource.value.get(); 1340 Resource* resource = documentResource.value.get();
1337 if (resource) 1341 if (resource)
1338 resource->reloadIfLoFiOrPlaceholderImage(this, Resource::kReloadAlways); 1342 resource->reloadIfLoFiOrPlaceholderImage(this, Resource::kReloadAlways);
kouhei (in TOK) 2017/03/15 10:25:28 or should we replace m_documentResources using the
hiroshige 2017/03/15 19:03:31 In fact I am sure that we update |m_documentResour
1339 } 1343 }
1340 } 1344 }
1341 1345
1342 void ResourceFetcher::logPreloadStats(ClearPreloadsPolicy policy) { 1346 void ResourceFetcher::logPreloadStats(ClearPreloadsPolicy policy) {
1343 if (!m_preloads) 1347 if (!m_preloads)
1344 return; 1348 return;
1345 unsigned scripts = 0; 1349 unsigned scripts = 0;
1346 unsigned scriptMisses = 0; 1350 unsigned scriptMisses = 0;
1347 unsigned stylesheets = 0; 1351 unsigned stylesheets = 0;
1348 unsigned stylesheetMisses = 0; 1352 unsigned stylesheetMisses = 0;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 visitor->trace(m_context); 1550 visitor->trace(m_context);
1547 visitor->trace(m_archive); 1551 visitor->trace(m_archive);
1548 visitor->trace(m_loaders); 1552 visitor->trace(m_loaders);
1549 visitor->trace(m_nonBlockingLoaders); 1553 visitor->trace(m_nonBlockingLoaders);
1550 visitor->trace(m_documentResources); 1554 visitor->trace(m_documentResources);
1551 visitor->trace(m_preloads); 1555 visitor->trace(m_preloads);
1552 visitor->trace(m_resourceTimingInfoMap); 1556 visitor->trace(m_resourceTimingInfoMap);
1553 } 1557 }
1554 1558
1555 } // namespace blink 1559 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698