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

Unified Diff: Source/core/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/core/loader/DocumentLoader.cpp
===================================================================
--- Source/core/loader/DocumentLoader.cpp (revision 148844)
+++ Source/core/loader/DocumentLoader.cpp (working copy)
@@ -274,20 +274,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(ResourceError::cancelledError(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(ResourceError::cancelledError(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(ResourceError::cancelledError(m_request.url()));
stopLoadingSubresources();
@@ -454,7 +452,7 @@
ASSERT(!newRequest.isNull());
if (!frameLoader()->checkIfFormActionAllowedByCSP(newRequest.url())) {
- cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
+ cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url()));
return;
}
@@ -465,7 +463,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(ResourceError::cancelledError(newRequest.url()));
return;
}
timing()->addRedirect(redirectResponse.url(), newRequest.url());
@@ -486,7 +484,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(ResourceError::cancelledError(newRequest.url()));
return;
}
}
@@ -584,7 +582,7 @@
frame()->document()->enforceSandboxFlags(SandboxOrigin);
if (HTMLFrameOwnerElement* ownerElement = frame()->ownerElement())
ownerElement->dispatchEvent(Event::create(eventNames().loadEvent, false, false));
- cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
+ cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()));
return;
}
}
@@ -620,7 +618,7 @@
// keep trying to process data from their load
if (hostedByObject)
- cancelMainResourceLoad(frameLoader()->cancelledError(m_request));
+ cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()));
}
}
@@ -653,14 +651,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);
}
@@ -904,6 +897,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();
@@ -923,10 +917,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());
}
}
}
@@ -1145,7 +1135,7 @@
void DocumentLoader::cancelMainResourceLoad(const ResourceError& resourceError)
{
RefPtr<DocumentLoader> protect(this);
- ResourceError error = resourceError.isNull() ? frameLoader()->cancelledError(m_request) : resourceError;
+ ResourceError error = resourceError.isNull() ? ResourceError::cancelledError(m_request.url()) : resourceError;
m_dataLoadTimer.stop();
if (mainResourceLoader())

Powered by Google App Engine
This is Rietveld 408576698