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

Unified Diff: Source/WebCore/loader/DocumentLoader.cpp

Issue 14264012: Create errors (especially cancellation errors) internally to WebCore, rather (Closed) Base URL: svn://svn.chromium.org/blink/trunk/
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: Source/WebCore/loader/DocumentLoader.cpp
===================================================================
--- Source/WebCore/loader/DocumentLoader.cpp (revision 148494)
+++ Source/WebCore/loader/DocumentLoader.cpp (working copy)
@@ -34,6 +34,7 @@
#include "ArchiveResourceCollection.h"
#include "CachedPage.h"
#include "CachedResourceLoader.h"
+#include "CancelledResourceError.h"
#include "DOMWindow.h"
#include "Document.h"
#include "DocumentParser.h"
@@ -276,20 +277,18 @@
return;
m_isStopping = true;
-
- FrameLoader* frameLoader = DocumentLoader::frameLoader();
if (isLoadingMainResource())
// Stop the main resource loader and let it send the cancelled message.
- cancelMainResourceLoad(frameLoader->cancelledError(m_request));
+ cancelMainResourceLoad(CancelledResourceError(m_request.url()));
else if (!m_resourceLoaders.isEmpty())
// The main resource loader already finished loading. Set the cancelled error on the
// document and let the resourceLoaders send individual cancelled messages below.
- setMainDocumentError(frameLoader->cancelledError(m_request));
+ setMainDocumentError(CancelledResourceError(m_request.url()));
else
// If there are no resource loaders, we need to manufacture a cancelled message.
// (A back/forward navigation has no resource loaders because its resources are cached.)
- mainReceivedError(frameLoader->cancelledError(m_request));
+ mainReceivedError(CancelledResourceError(m_request.url()));
stopLoadingSubresources();
@@ -426,7 +425,7 @@
ASSERT(!newRequest.isNull());
if (!frameLoader()->checkIfFormActionAllowedByCSP(newRequest.url())) {
- cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
+ cancelMainResourceLoad(CancelledResourceError(newRequest.url()));
return;
}
@@ -437,7 +436,7 @@
RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectResponse.url());
if (!redirectingOrigin->canDisplay(newRequest.url())) {
FrameLoader::reportLocalLoadFailed(m_frame, newRequest.url().string());
- cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
+ cancelMainResourceLoad(CancelledResourceError(newRequest.url()));
return;
}
timing()->addRedirect(redirectResponse.url(), newRequest.url());
@@ -458,7 +457,7 @@
Frame* top = m_frame->tree()->top();
if (top != m_frame) {
if (!frameLoader()->mixedContentChecker()->canDisplayInsecureContent(top->document()->securityOrigin(), newRequest.url())) {
- cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
+ cancelMainResourceLoad(CancelledResourceError(newRequest.url()));
return;
}
}
@@ -539,7 +538,7 @@
frame()->document()->enforceSandboxFlags(SandboxOrigin);
if (HTMLFrameOwnerElement* ownerElement = frame()->ownerElement())
ownerElement->dispatchEvent(Event::create(eventNames().loadEvent, false, false));
- cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
+ cancelMainResourceLoad(CancelledResourceError(m_request.url()));
return;
}
}
@@ -592,8 +591,7 @@
bool isRemoteWebArchive = equalIgnoringCase("multipart/related", mimeType)
&& !m_substituteData.isValid() && !SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol());
if (!frameLoader()->client()->canShowMIMEType(mimeType) || isRemoteWebArchive) {
- frameLoader()->policyChecker()->cannotShowMIMEType(m_response);
- // Check reachedTerminalState since the load may have already been canceled inside of _handleUnimplementablePolicyWithErrorCode::.
+ ASSERT_NOT_REACHED();
stopLoadingForPolicyChange();
return;
}
@@ -601,11 +599,7 @@
}
case PolicyDownload: {
- // m_mainResource can be null, e.g. when loading a substitute resource from application cache.
- if (!m_mainResource) {
- mainReceivedError(frameLoader()->client()->cannotShowURLError(m_request));
- return;
- }
+ ASSERT(m_mainResource);
InspectorInstrumentation::continueWithPolicyDownload(m_frame, this, mainResourceLoader()->identifier(), m_response);
// When starting the request, we didn't know that it would result in download and not navigation. Now we know that main document URL didn't change.
@@ -632,7 +626,7 @@
// keep trying to process data from their load
if (hostedByObject)
- cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
+ cancelMainResourceLoad(CancelledResourceError(m_request.url()));
}
}
@@ -665,14 +659,9 @@
frameLoader->client()->committedLoad(this, data, length);
}
-ResourceError DocumentLoader::interruptedForPolicyChangeError() const
-{
- return frameLoader()->client()->interruptedForPolicyChangeError(request());
-}
-
void DocumentLoader::stopLoadingForPolicyChange()
{
- ResourceError error = interruptedForPolicyChangeError();
+ ResourceError error = frameLoader()->client()->interruptedForPolicyChangeError(m_request);
error.setIsCancellation(true);
cancelMainResourceLoad(error);
}
@@ -926,6 +915,7 @@
for (SubstituteResourceMap::const_iterator it = copy.begin(); it != end; ++it) {
RefPtr<ResourceLoader> loader = it->key;
SubstituteResource* resource = it->value.get();
+ ASSERT(resource);
if (resource) {
SharedBuffer* data = resource->data();
@@ -945,10 +935,6 @@
return;
loader->didFinishLoading(0, 0);
- } else {
- // A null resource means that we should fail the load.
- // FIXME: Maybe we should use another error here - something like "not in cache".
- loader->didFail(0, loader->cannotShowURLError());
}
}
}
@@ -1167,7 +1153,7 @@
void DocumentLoader::cancelMainResourceLoad(const ResourceError& resourceError)
{
RefPtr<DocumentLoader> protect(this);
- ResourceError error = resourceError.isNull() ? frameLoader()->cancelledError(m_request) : resourceError;
+ ResourceError error = resourceError.isNull() ? CancelledResourceError(m_request.url()) : resourceError;
m_dataLoadTimer.stop();
if (m_waitingForContentPolicy) {

Powered by Google App Engine
This is Rietveld 408576698