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

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

Issue 1240503004: Revert of [XMLHttpRequest] Stop throwing for network error in async mode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 ddbde836da3c55855ac4d4c45b57722839c80089..bf26832ea0d32f46357eeee81ec981c8e2ed1d08 100644
--- a/Source/core/xmlhttprequest/XMLHttpRequest.cpp
+++ b/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -837,34 +837,11 @@
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") {
- handleNetworkError();
-
- if (!m_async) {
- throwForLoadFailureIfNeeded(exceptionState, "'GET' is the only method allowed for 'blob:' URLs.");
- }
+ exceptionState.throwDOMException(NetworkError, "'GET' is the only method allowed for 'blob:' URLs.");
return;
}
@@ -939,15 +916,16 @@
// FIXME: Maybe create() can return null for other reasons too?
ASSERT(!m_loader);
m_loader = ThreadableLoader::create(executionContext, this, request, options, resourceLoaderOptions);
-
- return;
- }
-
- // Use count for XHR synchronous requests.
- UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous);
- ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options, resourceLoaderOptions);
-
- throwForLoadFailureIfNeeded(exceptionState, String());
+ } else {
+ // Use count for XHR synchronous requests.
+ UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous);
+ ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options, resourceLoaderOptions);
+ }
+
+ if (!m_exceptionCode && m_error)
+ m_exceptionCode = NetworkError;
+ if (m_exceptionCode)
+ exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m_url.elidedString() + "'.");
}
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