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

Unified Diff: Source/core/xmlhttprequest/XMLHttpRequest.cpp

Issue 1060113004: [XMLHttpRequest] Stop throwing for network error in async mode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebease Created 5 years, 5 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
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/xmlhttprequest/XMLHttpRequest.cpp
diff --git a/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/Source/core/xmlhttprequest/XMLHttpRequest.cpp
index bf26832ea0d32f46357eeee81ec981c8e2ed1d08..ddbde836da3c55855ac4d4c45b57722839c80089 100644
--- a/Source/core/xmlhttprequest/XMLHttpRequest.cpp
+++ b/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -837,11 +837,34 @@ void XMLHttpRequest::sendForInspectorXHRReplay(PassRefPtr<FormData> formData, Ex
m_exceptionCode = exceptionState.code();
}
+void XMLHttpRequest::throwForLoadFailureIfNeeded(ExceptionState& exceptionState, const String& reason)
+{
+ if (m_error && !m_exceptionCode)
+ m_exceptionCode = NetworkError;
+
+ if (!m_exceptionCode)
+ return;
+
+ String message = "Failed to load '" + m_url.elidedString() + "'";
+ if (reason.isNull()) {
+ message.append(".");
+ } else {
+ message.append(": ");
+ message.append(reason);
+ }
+
+ exceptionState.throwDOMException(m_exceptionCode, message);
+}
+
void XMLHttpRequest::createRequest(PassRefPtr<FormData> httpBody, ExceptionState& exceptionState)
{
// Only GET request is supported for blob URL.
if (m_url.protocolIs("blob") && m_method != "GET") {
- exceptionState.throwDOMException(NetworkError, "'GET' is the only method allowed for 'blob:' URLs.");
+ handleNetworkError();
+
+ if (!m_async) {
+ throwForLoadFailureIfNeeded(exceptionState, "'GET' is the only method allowed for 'blob:' URLs.");
+ }
return;
}
@@ -916,16 +939,15 @@ void XMLHttpRequest::createRequest(PassRefPtr<FormData> httpBody, ExceptionState
// FIXME: Maybe create() can return null for other reasons too?
ASSERT(!m_loader);
m_loader = ThreadableLoader::create(executionContext, this, request, options, resourceLoaderOptions);
- } else {
- // Use count for XHR synchronous requests.
- UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous);
- ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options, resourceLoaderOptions);
+
+ return;
}
- if (!m_exceptionCode && m_error)
- m_exceptionCode = NetworkError;
- if (m_exceptionCode)
- exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m_url.elidedString() + "'.");
+ // Use count for XHR synchronous requests.
+ UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous);
+ ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options, resourceLoaderOptions);
+
+ throwForLoadFailureIfNeeded(exceptionState, String());
}
void XMLHttpRequest::abort()
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698