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

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

Issue 2748463002: Split header modification out of willSendRequest
Patch Set: bug fix 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 DCHECK(!substituteData.forceSynchronousLoad()); 498 DCHECK(!substituteData.forceSynchronousLoad());
499 return Block; 499 return Block;
500 } 500 }
501 501
502 context().willStartLoadingResource( 502 context().willStartLoadingResource(
503 identifier, resourceRequest, factory.type(), 503 identifier, resourceRequest, factory.type(),
504 request.options().initiatorInfo.name, 504 request.options().initiatorInfo.name,
505 (request.isSpeculativePreload() 505 (request.isSpeculativePreload()
506 ? FetchContext::V8ActivityLoggingPolicy::SuppressLogging 506 ? FetchContext::V8ActivityLoggingPolicy::SuppressLogging
507 : FetchContext::V8ActivityLoggingPolicy::Log)); 507 : FetchContext::V8ActivityLoggingPolicy::Log));
508 if (!request.url().isValid())
509 return Abort;
510 508
511 // Resource requests from suborigins should not be intercepted by the service 509 // Resource requests from suborigins should not be intercepted by the service
512 // worker of the physical origin. This has the effect that, for now, 510 // worker of the physical origin. This has the effect that, for now,
513 // suborigins do not work with service workers. See 511 // suborigins do not work with service workers. See
514 // https://w3c.github.io/webappsec-suborigins/. 512 // https://w3c.github.io/webappsec-suborigins/.
515 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); 513 SecurityOrigin* sourceOrigin = context().getSecurityOrigin();
516 if (sourceOrigin && sourceOrigin->hasSuborigin()) { 514 if (sourceOrigin && sourceOrigin->hasSuborigin()) {
517 resourceRequest.setServiceWorkerMode( 515 resourceRequest.setServiceWorkerMode(
518 WebURLRequest::ServiceWorkerMode::None); 516 WebURLRequest::ServiceWorkerMode::None);
519 } 517 }
520 518
521 resourceRequest.setAllowStoredCredentials( 519 resourceRequest.setAllowStoredCredentials(
522 request.options().allowCredentials == AllowStoredCredentials); 520 request.options().allowCredentials == AllowStoredCredentials);
521 context().prepareRequest(identifier, resourceRequest);
522
523 if (!request.url().isValid())
524 return Abort;
525
523 return Continue; 526 return Continue;
524 } 527 }
525 528
526 Resource* ResourceFetcher::requestResource( 529 Resource* ResourceFetcher::requestResource(
527 FetchRequest& request, 530 FetchRequest& request,
528 const ResourceFactory& factory, 531 const ResourceFactory& factory,
529 const SubstituteData& substituteData) { 532 const SubstituteData& substituteData) {
530 unsigned long identifier = createUniqueIdentifier(); 533 unsigned long identifier = createUniqueIdentifier();
531 ResourceRequest& resourceRequest = request.mutableResourceRequest(); 534 ResourceRequest& resourceRequest = request.mutableResourceRequest();
532 network_instrumentation::ScopedResourceLoadTracker scopedResourceLoadTracker( 535 network_instrumentation::ScopedResourceLoadTracker scopedResourceLoadTracker(
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1245 }
1243 1246
1244 bool ResourceFetcher::startLoad(Resource* resource) { 1247 bool ResourceFetcher::startLoad(Resource* resource) {
1245 DCHECK(resource); 1248 DCHECK(resource);
1246 DCHECK(resource->stillNeedsLoad()); 1249 DCHECK(resource->stillNeedsLoad());
1247 if (!context().shouldLoadNewResource(resource->getType())) { 1250 if (!context().shouldLoadNewResource(resource->getType())) {
1248 memoryCache()->remove(resource); 1251 memoryCache()->remove(resource);
1249 return false; 1252 return false;
1250 } 1253 }
1251 1254
1252 ResourceRequest request(resource->resourceRequest()); 1255 context().dispatchWillSendRequest(
1253 context().dispatchWillSendRequest(resource->identifier(), request, 1256 resource->identifier(), resource->resourceRequest(), ResourceResponse(),
1254 ResourceResponse(), 1257 resource->options().initiatorInfo);
1255 resource->options().initiatorInfo);
1256
1257 // TODO(shaochuan): Saving modified ResourceRequest back to |resource|, remove
1258 // once dispatchWillSendRequest() takes const ResourceRequest.
1259 // crbug.com/632580
1260 resource->setResourceRequest(request);
1261 1258
1262 ResourceLoader* loader = ResourceLoader::create(this, resource); 1259 ResourceLoader* loader = ResourceLoader::create(this, resource);
1263 if (resource->shouldBlockLoadEvent()) 1260 if (resource->shouldBlockLoadEvent())
1264 m_loaders.insert(loader); 1261 m_loaders.insert(loader);
1265 else 1262 else
1266 m_nonBlockingLoaders.insert(loader); 1263 m_nonBlockingLoaders.insert(loader);
1267 1264
1268 storePerformanceTimingInitiatorInformation(resource); 1265 storePerformanceTimingInitiatorInformation(resource);
1269 resource->setFetcherSecurityOrigin(context().getSecurityOrigin()); 1266 resource->setFetcherSecurityOrigin(context().getSecurityOrigin());
1270 1267
1271 loader->activateCacheAwareLoadingIfNeeded(request); 1268 loader->activateCacheAwareLoadingIfNeeded(resource->resourceRequest());
1272 loader->start(request); 1269 loader->start(resource->resourceRequest());
1273 return true; 1270 return true;
1274 } 1271 }
1275 1272
1276 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) { 1273 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) {
1277 DCHECK(loader); 1274 DCHECK(loader);
1278 if (m_loaders.contains(loader)) 1275 if (m_loaders.contains(loader))
1279 m_loaders.erase(loader); 1276 m_loaders.erase(loader);
1280 else if (m_nonBlockingLoaders.contains(loader)) 1277 else if (m_nonBlockingLoaders.contains(loader))
1281 m_nonBlockingLoaders.erase(loader); 1278 m_nonBlockingLoaders.erase(loader);
1282 else 1279 else
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 visitor->trace(m_context); 1545 visitor->trace(m_context);
1549 visitor->trace(m_archive); 1546 visitor->trace(m_archive);
1550 visitor->trace(m_loaders); 1547 visitor->trace(m_loaders);
1551 visitor->trace(m_nonBlockingLoaders); 1548 visitor->trace(m_nonBlockingLoaders);
1552 visitor->trace(m_documentResources); 1549 visitor->trace(m_documentResources);
1553 visitor->trace(m_preloads); 1550 visitor->trace(m_preloads);
1554 visitor->trace(m_resourceTimingInfoMap); 1551 visitor->trace(m_resourceTimingInfoMap);
1555 } 1552 }
1556 1553
1557 } // namespace blink 1554 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698