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

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

Powered by Google App Engine
This is Rietveld 408576698