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

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

Issue 2184823006: Call FetchContext::dispatchWillSendRequest() only if an actual load is started (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor 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
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/inspector/network/resources/font-face.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 if (!resource) 458 if (!resource)
459 resource = memoryCache()->resourceForURL(request.url(), getCacheIdentifi er()); 459 resource = memoryCache()->resourceForURL(request.url(), getCacheIdentifi er());
460 460
461 // See if we can use an existing resource from the cache. If so, we need to move it to be load blocking. 461 // See if we can use an existing resource from the cache. If so, we need to move it to be load blocking.
462 moveCachedNonBlockingResourceToBlocking(resource, request); 462 moveCachedNonBlockingResourceToBlocking(resource, request);
463 463
464 const RevalidationPolicy policy = determineRevalidationPolicy(factory.type() , request, resource, isStaticData); 464 const RevalidationPolicy policy = determineRevalidationPolicy(factory.type() , request, resource, isStaticData);
465 465
466 updateMemoryCacheStats(resource, policy, request, factory, isStaticData); 466 updateMemoryCacheStats(resource, policy, request, factory, isStaticData);
467 467
468 if (policy != Use) 468 request.mutableResourceRequest().setAllowStoredCredentials(request.options() .allowCredentials == AllowStoredCredentials);
469 willSendRequest(identifier, request.mutableResourceRequest(), ResourceRe sponse(), request.options());
470 469
471 switch (policy) { 470 switch (policy) {
472 case Reload: 471 case Reload:
473 memoryCache()->remove(resource); 472 memoryCache()->remove(resource);
474 // Fall through 473 // Fall through
475 case Load: 474 case Load:
476 resource = createResourceForLoading(request, request.charset(), factory) ; 475 resource = createResourceForLoading(request, request.charset(), factory) ;
477 break; 476 break;
478 case Revalidate: 477 case Revalidate:
479 initializeRevalidation(request.mutableResourceRequest(), resource); 478 initializeRevalidation(request.mutableResourceRequest(), resource);
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 } 983 }
985 984
986 bool ResourceFetcher::startLoad(Resource* resource) 985 bool ResourceFetcher::startLoad(Resource* resource)
987 { 986 {
988 DCHECK(resource && resource->stillNeedsLoad()); 987 DCHECK(resource && resource->stillNeedsLoad());
989 if (!context().shouldLoadNewResource(resource->getType())) { 988 if (!context().shouldLoadNewResource(resource->getType())) {
990 memoryCache()->remove(resource); 989 memoryCache()->remove(resource);
991 return false; 990 return false;
992 } 991 }
993 992
993 ResourceRequest request(resource->resourceRequest());
Nate Chapin 2016/07/28 17:20:37 It'd be nice if we could eventually return to a si
hiroshige 2016/07/29 05:59:24 Agree. Filed crbug.com/632580. Splitting willSend
994 willSendRequest(resource->identifier(), request, ResourceResponse(), resourc e->options());
995
994 ResourceLoader* loader = ResourceLoader::create(this, resource); 996 ResourceLoader* loader = ResourceLoader::create(this, resource);
995 if (resource->shouldBlockLoadEvent()) 997 if (resource->shouldBlockLoadEvent())
996 m_loaders.add(loader); 998 m_loaders.add(loader);
997 else 999 else
998 m_nonBlockingLoaders.add(loader); 1000 m_nonBlockingLoaders.add(loader);
999 1001
1000 storeResourceTimingInitiatorInformation(resource); 1002 storeResourceTimingInitiatorInformation(resource);
1001 resource->setFetcherSecurityOrigin(context().getSecurityOrigin()); 1003 resource->setFetcherSecurityOrigin(context().getSecurityOrigin());
1002 loader->start(resource->resourceRequest(), context().loadingTaskRunner(), co ntext().defersLoading()); 1004 loader->start(request, context().loadingTaskRunner(), context().defersLoadin g());
1003 return true; 1005 return true;
1004 } 1006 }
1005 1007
1006 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) 1008 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader)
1007 { 1009 {
1008 if (m_loaders.contains(loader)) 1010 if (m_loaders.contains(loader))
1009 m_loaders.remove(loader); 1011 m_loaders.remove(loader);
1010 else if (m_nonBlockingLoaders.contains(loader)) 1012 else if (m_nonBlockingLoaders.contains(loader))
1011 m_nonBlockingLoaders.remove(loader); 1013 m_nonBlockingLoaders.remove(loader);
1012 else 1014 else
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 return false; 1064 return false;
1063 } 1065 }
1064 1066
1065 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); 1067 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource);
1066 if (it != m_resourceTimingInfoMap.end()) { 1068 if (it != m_resourceTimingInfoMap.end()) {
1067 RefPtr<SecurityOrigin> originalSecurityOrigin = SecurityOrigin::create(r edirectResponse.url()); 1069 RefPtr<SecurityOrigin> originalSecurityOrigin = SecurityOrigin::create(r edirectResponse.url());
1068 RefPtr<SecurityOrigin> redirectedSecurityOrigin = SecurityOrigin::create (newRequest.url()); 1070 RefPtr<SecurityOrigin> redirectedSecurityOrigin = SecurityOrigin::create (newRequest.url());
1069 bool crossOrigin = !redirectedSecurityOrigin->isSameSchemeHostPort(origi nalSecurityOrigin.get()); 1071 bool crossOrigin = !redirectedSecurityOrigin->isSameSchemeHostPort(origi nalSecurityOrigin.get());
1070 it->value->addRedirect(redirectResponse, encodedDataLength, crossOrigin) ; 1072 it->value->addRedirect(redirectResponse, encodedDataLength, crossOrigin) ;
1071 } 1073 }
1074 newRequest.setAllowStoredCredentials(resource->options().allowCredentials == AllowStoredCredentials);
1072 willSendRequest(resource->identifier(), newRequest, redirectResponse, resour ce->options()); 1075 willSendRequest(resource->identifier(), newRequest, redirectResponse, resour ce->options());
1073 return true; 1076 return true;
1074 } 1077 }
1075 1078
1076 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest& newRequest, const ResourceResponse& redirectResponse, const ResourceLoaderOptio ns& options) 1079 void ResourceFetcher::willSendRequest(unsigned long identifier, ResourceRequest& newRequest, const ResourceResponse& redirectResponse, const ResourceLoaderOptio ns& options)
1077 { 1080 {
1078 newRequest.setAllowStoredCredentials(options.allowCredentials == AllowStored Credentials);
1079 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, options.initiatorInfo); 1081 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, options.initiatorInfo);
1080 } 1082 }
1081 1083
1082 void ResourceFetcher::updateAllImageResourcePriorities() 1084 void ResourceFetcher::updateAllImageResourcePriorities()
1083 { 1085 {
1084 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource Priorities"); 1086 TRACE_EVENT0("blink", "ResourceLoadPriorityOptimizer::updateAllImageResource Priorities");
1085 for (const auto& documentResource : m_documentResources) { 1087 for (const auto& documentResource : m_documentResources) {
1086 Resource* resource = documentResource.value.get(); 1088 Resource* resource = documentResource.value.get();
1087 if (!resource || !resource->isImage() || !resource->isLoading()) 1089 if (!resource || !resource->isImage() || !resource->isLoading())
1088 continue; 1090 continue;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 visitor->trace(m_context); 1274 visitor->trace(m_context);
1273 visitor->trace(m_archive); 1275 visitor->trace(m_archive);
1274 visitor->trace(m_loaders); 1276 visitor->trace(m_loaders);
1275 visitor->trace(m_nonBlockingLoaders); 1277 visitor->trace(m_nonBlockingLoaders);
1276 visitor->trace(m_documentResources); 1278 visitor->trace(m_documentResources);
1277 visitor->trace(m_preloads); 1279 visitor->trace(m_preloads);
1278 visitor->trace(m_resourceTimingInfoMap); 1280 visitor->trace(m_resourceTimingInfoMap);
1279 } 1281 }
1280 1282
1281 } // namespace blink 1283 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/inspector/network/resources/font-face.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698