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

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: Addressed #12 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 239b35139a9d28652532e21320bec285f22c2ebf..3f6516ece7e0562f9a6d74efd6c59ea3981a876b 100644
--- a/Source/core/xmlhttprequest/XMLHttpRequest.cpp
+++ b/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -832,11 +832,30 @@ 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;
sof 2015/07/14 07:07:01 Add an early return if !m_exceptionCode ?
tyoshino (SeeGerritForStatus) 2015/07/14 08:48:55 Done.
+
+ String message = "Failed to load '" + m_url.elidedString() + "'";
+ if (!message.isNull()) {
+ message.append(": ");
+ message.append(reason);
+ }
+
+ if (m_exceptionCode)
+ 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;
}
@@ -911,16 +930,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