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

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

Issue 2395313002: Revert of Make ResourceFetcher return Resources with LoadError instead of nullptrs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 case Resource::ImportResource: 183 case Resource::ImportResource:
184 resource = RawResource::fetchImport(request, fetcher()); 184 resource = RawResource::fetchImport(request, fetcher());
185 break; 185 break;
186 case Resource::Raw: 186 case Resource::Raw:
187 resource = RawResource::fetch(request, fetcher()); 187 resource = RawResource::fetch(request, fetcher());
188 break; 188 break;
189 default: 189 default:
190 NOTREACHED(); 190 NOTREACHED();
191 } 191 }
192 192
193 // CSP layout tests verify that preloads are subject to access checks by 193 if (resource)
194 // seeing if they are in the `preload started` list. Therefore do not add
195 // them to the list if the load is immediately denied.
196 if (resource && !resource->resourceError().isAccessCheck())
197 fetcher()->preloadStarted(resource); 194 fetcher()->preloadStarted(resource);
198 return resource; 195 return resource;
199 } 196 }
200 197
201 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) { 198 void DocumentLoader::didRedirect(const KURL& oldURL, const KURL& newURL) {
202 timing().addRedirect(oldURL, newURL); 199 timing().addRedirect(oldURL, newURL);
203 200
204 // If a redirection happens during a back/forward navigation, don't restore 201 // If a redirection happens during a back/forward navigation, don't restore
205 // any state from the old HistoryItem. There is a provisional history item for 202 // any state from the old HistoryItem. There is a provisional history item for
206 // back/forward navigation only. In the other case, clearing it is a no-op. 203 // back/forward navigation only. In the other case, clearing it is a no-op.
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } 674 }
678 675
679 DEFINE_STATIC_LOCAL( 676 DEFINE_STATIC_LOCAL(
680 ResourceLoaderOptions, mainResourceLoadOptions, 677 ResourceLoaderOptions, mainResourceLoadOptions,
681 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, 678 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials,
682 CheckContentSecurityPolicy, DocumentContext)); 679 CheckContentSecurityPolicy, DocumentContext));
683 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, 680 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document,
684 mainResourceLoadOptions); 681 mainResourceLoadOptions);
685 m_mainResource = 682 m_mainResource =
686 RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData); 683 RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData);
687 684 if (!m_mainResource) {
688 // PlzNavigate:
689 // The final access checks are still performed here, potentially rejecting
690 // the "provisional" load, but the browser side already expects the renderer
691 // to be able to unconditionally commit.
692 if (!m_mainResource || (m_frame->settings()->browserSideNavigationEnabled() &&
693 m_mainResource->errorOccurred())) {
694 m_request = ResourceRequest(blankURL()); 685 m_request = ResourceRequest(blankURL());
695 maybeLoadEmpty(); 686 maybeLoadEmpty();
696 return; 687 return;
697 } 688 }
698 // A bunch of headers are set when the underlying resource load begins, and 689 // A bunch of headers are set when the underlying resource load begins, and
699 // m_request needs to include those. Even when using a cached resource, we may 690 // m_request needs to include those. Even when using a cached resource, we may
700 // make some modification to the request, e.g. adding the referer header. 691 // make some modification to the request, e.g. adding the referer header.
701 m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest() 692 m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest()
702 : fetchRequest.resourceRequest(); 693 : fetchRequest.resourceRequest();
703 m_mainResource->addClient(this); 694 m_mainResource->addClient(this);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 m_writer ? m_writer->encoding() : emptyAtom, true, 752 m_writer ? m_writer->encoding() : emptyAtom, true,
762 ForceSynchronousParsing); 753 ForceSynchronousParsing);
763 if (!source.isNull()) 754 if (!source.isNull())
764 m_writer->appendReplacingData(source); 755 m_writer->appendReplacingData(source);
765 endWriting(m_writer.get()); 756 endWriting(m_writer.get());
766 } 757 }
767 758
768 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 759 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
769 760
770 } // namespace blink 761 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698