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

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

Issue 2738303005: Move suborigin/serviceworker processing to ResourceFetcher::prepareRequest()
Patch Set: Rebase 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
« no previous file with comments | « no previous file | 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 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()) 508 if (!request.url().isValid())
509 return Abort; 509 return Abort;
510 510
511 // Resource requests from suborigins should not be intercepted by the service
512 // worker of the physical origin. This has the effect that, for now,
513 // suborigins do not work with service workers. See
514 // https://w3c.github.io/webappsec-suborigins/.
515 SecurityOrigin* sourceOrigin = context().getSecurityOrigin();
516 if (sourceOrigin && sourceOrigin->hasSuborigin()) {
517 resourceRequest.setServiceWorkerMode(
518 WebURLRequest::ServiceWorkerMode::None);
519 }
520
511 resourceRequest.setAllowStoredCredentials( 521 resourceRequest.setAllowStoredCredentials(
512 request.options().allowCredentials == AllowStoredCredentials); 522 request.options().allowCredentials == AllowStoredCredentials);
513 return Continue; 523 return Continue;
514 } 524 }
515 525
516 Resource* ResourceFetcher::requestResource( 526 Resource* ResourceFetcher::requestResource(
517 FetchRequest& request, 527 FetchRequest& request,
518 const ResourceFactory& factory, 528 const ResourceFactory& factory,
519 const SubstituteData& substituteData) { 529 const SubstituteData& substituteData) {
520 unsigned long identifier = createUniqueIdentifier(); 530 unsigned long identifier = createUniqueIdentifier();
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 ResourceRequest request(resource->resourceRequest()); 1252 ResourceRequest request(resource->resourceRequest());
1243 context().dispatchWillSendRequest(resource->identifier(), request, 1253 context().dispatchWillSendRequest(resource->identifier(), request,
1244 ResourceResponse(), 1254 ResourceResponse(),
1245 resource->options().initiatorInfo); 1255 resource->options().initiatorInfo);
1246 1256
1247 // TODO(shaochuan): Saving modified ResourceRequest back to |resource|, remove 1257 // TODO(shaochuan): Saving modified ResourceRequest back to |resource|, remove
1248 // once dispatchWillSendRequest() takes const ResourceRequest. 1258 // once dispatchWillSendRequest() takes const ResourceRequest.
1249 // crbug.com/632580 1259 // crbug.com/632580
1250 resource->setResourceRequest(request); 1260 resource->setResourceRequest(request);
1251 1261
1252 // Resource requests from suborigins should not be intercepted by the service
1253 // worker of the physical origin. This has the effect that, for now,
1254 // suborigins do not work with service workers. See
1255 // https://w3c.github.io/webappsec-suborigins/.
1256 SecurityOrigin* sourceOrigin = context().getSecurityOrigin();
1257 if (sourceOrigin && sourceOrigin->hasSuborigin())
1258 request.setServiceWorkerMode(WebURLRequest::ServiceWorkerMode::None);
1259
1260 ResourceLoader* loader = ResourceLoader::create(this, resource); 1262 ResourceLoader* loader = ResourceLoader::create(this, resource);
1261 if (resource->shouldBlockLoadEvent()) 1263 if (resource->shouldBlockLoadEvent())
1262 m_loaders.insert(loader); 1264 m_loaders.insert(loader);
1263 else 1265 else
1264 m_nonBlockingLoaders.insert(loader); 1266 m_nonBlockingLoaders.insert(loader);
1265 1267
1266 storePerformanceTimingInitiatorInformation(resource); 1268 storePerformanceTimingInitiatorInformation(resource);
1267 resource->setFetcherSecurityOrigin(sourceOrigin); 1269 resource->setFetcherSecurityOrigin(context().getSecurityOrigin());
1268 1270
1269 loader->activateCacheAwareLoadingIfNeeded(request); 1271 loader->activateCacheAwareLoadingIfNeeded(request);
1270 loader->start(request); 1272 loader->start(request);
1271 return true; 1273 return true;
1272 } 1274 }
1273 1275
1274 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) { 1276 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) {
1275 DCHECK(loader); 1277 DCHECK(loader);
1276 if (m_loaders.contains(loader)) 1278 if (m_loaders.contains(loader))
1277 m_loaders.erase(loader); 1279 m_loaders.erase(loader);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 visitor->trace(m_context); 1548 visitor->trace(m_context);
1547 visitor->trace(m_archive); 1549 visitor->trace(m_archive);
1548 visitor->trace(m_loaders); 1550 visitor->trace(m_loaders);
1549 visitor->trace(m_nonBlockingLoaders); 1551 visitor->trace(m_nonBlockingLoaders);
1550 visitor->trace(m_documentResources); 1552 visitor->trace(m_documentResources);
1551 visitor->trace(m_preloads); 1553 visitor->trace(m_preloads);
1552 visitor->trace(m_resourceTimingInfoMap); 1554 visitor->trace(m_resourceTimingInfoMap);
1553 } 1555 }
1554 1556
1555 } // namespace blink 1557 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698