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

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

Issue 18548003: Rename ExceptionCode constants to use the names in the spec (2/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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/workers/WorkerGlobalScope.cpp ('k') | Source/core/xml/XMLSerializer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/xml/XMLHttpRequest.cpp
diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp
index 4a628c4a456ccd76593a506fee0526ae0fdc1dd2..e2c944284bf01bc0ec090946991072f6d9975abc 100644
--- a/Source/core/xml/XMLHttpRequest.cpp
+++ b/Source/core/xml/XMLHttpRequest.cpp
@@ -215,7 +215,7 @@ XMLHttpRequest::State XMLHttpRequest::readyState() const
ScriptString XMLHttpRequest::responseText(ExceptionCode& ec)
{
if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != ResponseTypeText) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return ScriptString();
}
if (m_error || (m_state != LOADING && m_state != DONE))
@@ -226,7 +226,7 @@ ScriptString XMLHttpRequest::responseText(ExceptionCode& ec)
Document* XMLHttpRequest::responseXML(ExceptionCode& ec)
{
if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != ResponseTypeDocument) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return 0;
}
@@ -263,7 +263,7 @@ Document* XMLHttpRequest::responseXML(ExceptionCode& ec)
Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec)
{
if (m_responseTypeCode != ResponseTypeBlob) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return 0;
}
// We always return null before DONE.
@@ -298,7 +298,7 @@ Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec)
ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec)
{
if (m_responseTypeCode != ResponseTypeArrayBuffer) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return 0;
}
@@ -319,7 +319,7 @@ void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec)
// XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set while fetching is in progress. If that occurs it will still be measured relative to the start of fetching."
if (scriptExecutionContext()->isDocument() && !m_async) {
logConsoleError(scriptExecutionContext(), "XMLHttpRequest.timeout cannot be set for synchronous HTTP(S) requests made from the window context.");
- ec = INVALID_ACCESS_ERR;
+ ec = InvalidAccessError;
return;
}
m_timeoutMilliseconds = timeout;
@@ -328,7 +328,7 @@ void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec)
void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& ec)
{
if (m_state >= LOADING) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return;
}
@@ -338,7 +338,7 @@ void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode&
// such as file: and data: still make sense to allow.
if (!m_async && scriptExecutionContext()->isDocument() && m_url.protocolIsInHTTPFamily()) {
logConsoleError(scriptExecutionContext(), "XMLHttpRequest.responseType cannot be changed for synchronous HTTP(S) requests made from the window context.");
- ec = INVALID_ACCESS_ERR;
+ ec = InvalidAccessError;
return;
}
@@ -410,7 +410,7 @@ void XMLHttpRequest::callReadyStateChangeListener()
void XMLHttpRequest::setWithCredentials(bool value, ExceptionCode& ec)
{
if (m_state > OPENED || m_loader) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return;
}
@@ -463,25 +463,25 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc
ASSERT(m_state == UNSENT);
if (!isValidHTTPToken(method)) {
- ec = SYNTAX_ERR;
+ ec = SyntaxError;
return;
}
if (!isAllowedHTTPMethod(method)) {
- ec = SECURITY_ERR;
+ ec = SecurityError;
return;
}
if (!ContentSecurityPolicy::shouldBypassMainWorld(scriptExecutionContext()) && !scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)) {
// FIXME: Should this be throwing an exception?
- ec = SECURITY_ERR;
+ ec = SecurityError;
return;
}
if (!async && scriptExecutionContext()->isDocument()) {
if (document()->settings() && !document()->settings()->syncXHRInDocumentsEnabled()) {
logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpRequests are disabled for this page.");
- ec = INVALID_ACCESS_ERR;
+ ec = InvalidAccessError;
return;
}
@@ -491,14 +491,14 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc
// such as file: and data: still make sense to allow.
if (url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDefault) {
logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) requests made from the window context cannot have XMLHttpRequest.responseType set.");
- ec = INVALID_ACCESS_ERR;
+ ec = InvalidAccessError;
return;
}
// Similarly, timeouts are disabled for synchronous requests as well.
if (m_timeoutMilliseconds > 0) {
logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpRequests must not have a timeout value set.");
- ec = INVALID_ACCESS_ERR;
+ ec = InvalidAccessError;
return;
}
}
@@ -542,7 +542,7 @@ bool XMLHttpRequest::initSend(ExceptionCode& ec)
return false;
if (m_state != OPENED || m_loader) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return false;
}
@@ -904,12 +904,12 @@ void XMLHttpRequest::overrideMimeType(const String& override)
void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& value, ExceptionCode& ec)
{
if (m_state != OPENED || m_loader) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return;
}
if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value)) {
- ec = SYNTAX_ERR;
+ ec = SyntaxError;
return;
}
@@ -937,7 +937,7 @@ String XMLHttpRequest::getRequestHeader(const AtomicString& name) const
String XMLHttpRequest::getAllResponseHeaders(ExceptionCode& ec) const
{
if (m_state < HEADERS_RECEIVED) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return "";
}
@@ -973,7 +973,7 @@ String XMLHttpRequest::getAllResponseHeaders(ExceptionCode& ec) const
String XMLHttpRequest::getResponseHeader(const AtomicString& name, ExceptionCode& ec) const
{
if (m_state < HEADERS_RECEIVED) {
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
return String();
}
@@ -1023,7 +1023,7 @@ int XMLHttpRequest::status(ExceptionCode& ec) const
if (m_state == OPENED) {
// Firefox only raises an exception in this state; we match it.
// Note the case of local file requests, where we have no HTTP response code! Firefox never raises an exception for those, but we match HTTP case for consistency.
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
}
return 0;
@@ -1036,7 +1036,7 @@ String XMLHttpRequest::statusText(ExceptionCode& ec) const
if (m_state == OPENED) {
// See comments in status() above.
- ec = INVALID_STATE_ERR;
+ ec = InvalidStateError;
}
return String();
« no previous file with comments | « Source/core/workers/WorkerGlobalScope.cpp ('k') | Source/core/xml/XMLSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698