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

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

Issue 2747203002: Make prepareRequest() a separate callback of FetchContext (Closed)
Patch Set: addressed comments 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 /* Don't send security violation reports for speculative preloads */ 499 /* Don't send security violation reports for speculative preloads */
500 request.isSpeculativePreload() 500 request.isSpeculativePreload()
501 ? SecurityViolationReportingPolicy::SuppressReporting 501 ? SecurityViolationReportingPolicy::SuppressReporting
502 : SecurityViolationReportingPolicy::Report, 502 : SecurityViolationReportingPolicy::Report,
503 request.getOriginRestriction()); 503 request.getOriginRestriction());
504 if (blockedReason != ResourceRequestBlockedReason::None) { 504 if (blockedReason != ResourceRequestBlockedReason::None) {
505 DCHECK(!substituteData.forceSynchronousLoad()); 505 DCHECK(!substituteData.forceSynchronousLoad());
506 return Block; 506 return Block;
507 } 507 }
508 508
509 context().willStartLoadingResource( 509 // For initial requests, call prepareRequest() here before revalidation
510 identifier, resourceRequest, factory.type(), 510 // policy is determined.
511 request.options().initiatorInfo.name, 511 context().prepareRequest(resourceRequest,
512 (request.isSpeculativePreload() 512 FetchContext::RedirectType::kNotForRedirect);
513 ? FetchContext::V8ActivityLoggingPolicy::SuppressLogging 513
514 : FetchContext::V8ActivityLoggingPolicy::Log));
515 if (!request.url().isValid()) 514 if (!request.url().isValid())
516 return Abort; 515 return Abort;
517 516
518 resourceRequest.setAllowStoredCredentials( 517 resourceRequest.setAllowStoredCredentials(
519 request.options().allowCredentials == AllowStoredCredentials); 518 request.options().allowCredentials == AllowStoredCredentials);
520 return Continue; 519 return Continue;
521 } 520 }
522 521
523 Resource* ResourceFetcher::requestResource( 522 Resource* ResourceFetcher::requestResource(
524 FetchRequest& request, 523 FetchRequest& request,
(...skipping 12 matching lines...) Expand all
537 ResourceRequestBlockedReason blockedReason = 536 ResourceRequestBlockedReason blockedReason =
538 ResourceRequestBlockedReason::None; 537 ResourceRequestBlockedReason::None;
539 538
540 PrepareRequestResult result = prepareRequest(request, factory, substituteData, 539 PrepareRequestResult result = prepareRequest(request, factory, substituteData,
541 identifier, blockedReason); 540 identifier, blockedReason);
542 if (result == Abort) 541 if (result == Abort)
543 return nullptr; 542 return nullptr;
544 if (result == Block) 543 if (result == Block)
545 return resourceForBlockedRequest(request, factory, blockedReason); 544 return resourceForBlockedRequest(request, factory, blockedReason);
546 545
546 if (!request.isSpeculativePreload()) {
547 // Only log if it's not for speculative preload.
548 context().recordLoadingActivity(identifier, resourceRequest, factory.type(),
549 request.options().initiatorInfo.name);
550 }
551
547 bool isDataUrl = resourceRequest.url().protocolIsData(); 552 bool isDataUrl = resourceRequest.url().protocolIsData();
548 bool isStaticData = isDataUrl || substituteData.isValid() || m_archive; 553 bool isStaticData = isDataUrl || substituteData.isValid() || m_archive;
549 if (isStaticData) { 554 if (isStaticData) {
550 resource = resourceForStaticData(request, factory, substituteData); 555 resource = resourceForStaticData(request, factory, substituteData);
551 // Abort the request if the archive doesn't contain the resource, except in 556 // Abort the request if the archive doesn't contain the resource, except in
552 // the case of data URLs which might have resources such as fonts that need 557 // the case of data URLs which might have resources such as fonts that need
553 // to be decoded only on demand. These data URLs are allowed to be 558 // to be decoded only on demand. These data URLs are allowed to be
554 // processed using the normal ResourceFetcher machinery. 559 // processed using the normal ResourceFetcher machinery.
555 if (!resource && !isDataUrl && m_archive) 560 if (!resource && !isDataUrl && m_archive)
556 return nullptr; 561 return nullptr;
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 visitor->trace(m_context); 1548 visitor->trace(m_context);
1544 visitor->trace(m_archive); 1549 visitor->trace(m_archive);
1545 visitor->trace(m_loaders); 1550 visitor->trace(m_loaders);
1546 visitor->trace(m_nonBlockingLoaders); 1551 visitor->trace(m_nonBlockingLoaders);
1547 visitor->trace(m_documentResources); 1552 visitor->trace(m_documentResources);
1548 visitor->trace(m_preloads); 1553 visitor->trace(m_preloads);
1549 visitor->trace(m_resourceTimingInfoMap); 1554 visitor->trace(m_resourceTimingInfoMap);
1550 } 1555 }
1551 1556
1552 } // namespace blink 1557 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698