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

Side by Side Diff: third_party/WebKit/Source/core/loader/DocumentLoader.cpp

Issue 2231523002: Make ResourceFetcher return Resources with LoadError instead of nullptrs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment phrasing. Created 4 years, 2 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) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 case Resource::ImportResource: 192 case Resource::ImportResource:
193 resource = RawResource::fetchImport(request, fetcher()); 193 resource = RawResource::fetchImport(request, fetcher());
194 break; 194 break;
195 case Resource::Raw: 195 case Resource::Raw:
196 resource = RawResource::fetch(request, fetcher()); 196 resource = RawResource::fetch(request, fetcher());
197 break; 197 break;
198 default: 198 default:
199 NOTREACHED(); 199 NOTREACHED();
200 } 200 }
201 201
202 if (resource) 202 // CSP layout tests verify that preloads are subject to access checks by
203 // seeing if they are in the `preload started` list. Therefore do not add
204 // them to the list if the load is immediately denied.
205 if (resource && !resource->resourceError().isAccessCheck())
203 fetcher()->preloadStarted(resource); 206 fetcher()->preloadStarted(resource);
204 return resource; 207 return resource;
205 } 208 }
206 209
207 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) 210 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL)
208 { 211 {
209 timing().addRedirect(oldURL, newURL); 212 timing().addRedirect(oldURL, newURL);
210 213
211 // If a redirection happens during a back/forward navigation, don't restore 214 // If a redirection happens during a back/forward navigation, don't restore
212 // any state from the old HistoryItem. 215 // any state from the old HistoryItem.
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 // The fetch has already started in the browser. Don't mark it again. 658 // The fetch has already started in the browser. Don't mark it again.
656 if (!m_frame->settings()->browserSideNavigationEnabled()) { 659 if (!m_frame->settings()->browserSideNavigationEnabled()) {
657 DCHECK(!timing().fetchStart()); 660 DCHECK(!timing().fetchStart());
658 timing().markFetchStart(); 661 timing().markFetchStart();
659 } 662 }
660 663
661 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, 664 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
662 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext)); 665 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext));
663 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions); 666 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main ResourceLoadOptions);
664 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData); 667 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s ubstituteData);
665 if (!m_mainResource) { 668
669 // PlzNavigate:
670 // The final access checks are still performed here, potentially rejecting
671 // the "provisional" load, but the browser side already expects the renderer
672 // to be able to unconditionally commit.
673 if (!m_mainResource || (m_frame->settings()->browserSideNavigationEnabled() && m_mainResource->errorOccurred())) {
engedy 2016/09/30 16:03:15 Nate, this is new, please take a look. The theore
clamy 2016/10/04 14:49:53 I'm not sure I understand fully: is this needed fo
engedy 2016/10/04 23:11:22 Thanks for clarifying. And yes -- then the proxim
alexmos 2016/10/05 20:58:52 I ran into similar issues with OOPIFs and CSP bloc
engedy 2016/10/05 23:26:25 Yes, that's my understanding.
alexmos 2016/10/06 00:24:06 Not sure about layout tests for this. On the brow
engedy 2016/10/06 00:32:14 All right, will make mention of this on the bug.
666 m_request = ResourceRequest(blankURL()); 674 m_request = ResourceRequest(blankURL());
667 maybeLoadEmpty(); 675 maybeLoadEmpty();
668 return; 676 return;
669 } 677 }
670 // A bunch of headers are set when the underlying resource load begins, and m_request needs to include those. 678 // A bunch of headers are set when the underlying resource load begins, and m_request needs to include those.
671 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header. 679 // Even when using a cached resource, we may make some modification to the r equest, e.g. adding the referer header.
672 m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest() : fetchRequest.resourceRequest(); 680 m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest() : fetchRequest.resourceRequest();
673 m_mainResource->addClient(this); 681 m_mainResource->addClient(this);
674 } 682 }
675 683
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 { 728 {
721 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing); 729 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing);
722 if (!source.isNull()) 730 if (!source.isNull())
723 m_writer->appendReplacingData(source); 731 m_writer->appendReplacingData(source);
724 endWriting(m_writer.get()); 732 endWriting(m_writer.get());
725 } 733 }
726 734
727 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 735 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
728 736
729 } // namespace blink 737 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698