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

Unified Diff: Source/modules/websockets/WebSocket.cpp

Issue 19724003: Revert "Transition modules/** to use ExceptionState" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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/modules/websockets/WebSocket.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/websockets/WebSocket.cpp
diff --git a/Source/modules/websockets/WebSocket.cpp b/Source/modules/websockets/WebSocket.cpp
index 9016a538928649449bae969c589595524b5a0b9d..caa0d0f795dc432bf7b503a1a442db427b37d02e 100644
--- a/Source/modules/websockets/WebSocket.cpp
+++ b/Source/modules/websockets/WebSocket.cpp
@@ -32,7 +32,6 @@
#include "modules/websockets/WebSocket.h"
-#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/ScriptController.h"
#include "core/dom/Document.h"
#include "core/dom/Event.h"
@@ -155,50 +154,50 @@ PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context)
return webSocket.release();
}
-PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, ExceptionState& es)
+PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, ExceptionCode& ec)
{
Vector<String> protocols;
- return WebSocket::create(context, url, protocols, es);
+ return WebSocket::create(context, url, protocols, ec);
}
-PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, const Vector<String>& protocols, ExceptionState& es)
+PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, const Vector<String>& protocols, ExceptionCode& ec)
{
if (url.isNull()) {
- es.throwDOMException(SyntaxError);
+ ec = SyntaxError;
return 0;
}
RefPtr<WebSocket> webSocket(adoptRef(new WebSocket(context)));
webSocket->suspendIfNeeded();
- webSocket->connect(context->completeURL(url), protocols, es);
- if (es.hadException())
+ webSocket->connect(context->completeURL(url), protocols, ec);
+ if (ec)
return 0;
return webSocket.release();
}
-PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, const String& protocol, ExceptionState& es)
+PassRefPtr<WebSocket> WebSocket::create(ScriptExecutionContext* context, const String& url, const String& protocol, ExceptionCode& ec)
{
Vector<String> protocols;
protocols.append(protocol);
- return WebSocket::create(context, url, protocols, es);
+ return WebSocket::create(context, url, protocols, ec);
}
-void WebSocket::connect(const String& url, ExceptionState& es)
+void WebSocket::connect(const String& url, ExceptionCode& ec)
{
Vector<String> protocols;
- connect(url, protocols, es);
+ connect(url, protocols, ec);
}
-void WebSocket::connect(const String& url, const String& protocol, ExceptionState& es)
+void WebSocket::connect(const String& url, const String& protocol, ExceptionCode& ec)
{
Vector<String> protocols;
protocols.append(protocol);
- connect(url, protocols, es);
+ connect(url, protocols, ec);
}
-void WebSocket::connect(const String& url, const Vector<String>& protocols, ExceptionState& es)
+void WebSocket::connect(const String& url, const Vector<String>& protocols, ExceptionCode& ec)
{
LOG(Network, "WebSocket %p connect() url='%s'", this, url.utf8().data());
m_url = KURL(KURL(), url);
@@ -206,26 +205,26 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
if (!m_url.isValid()) {
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Invalid url for WebSocket " + m_url.elidedString());
m_state = CLOSED;
- es.throwDOMException(SyntaxError);
+ ec = SyntaxError;
return;
}
if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) {
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Wrong url scheme for WebSocket " + m_url.elidedString());
m_state = CLOSED;
- es.throwDOMException(SyntaxError);
+ ec = SyntaxError;
return;
}
if (m_url.hasFragmentIdentifier()) {
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "URL has fragment component " + m_url.elidedString());
m_state = CLOSED;
- es.throwDOMException(SyntaxError);
+ ec = SyntaxError;
return;
}
if (!portAllowed(m_url)) {
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "WebSocket port " + String::number(m_url.port()) + " blocked");
m_state = CLOSED;
- es.throwDOMException(SecurityError);
+ ec = SecurityError;
return;
}
@@ -239,7 +238,7 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
m_state = CLOSED;
// FIXME: Should this be throwing an exception?
- es.throwDOMException(SecurityError);
+ ec = SecurityError;
return;
}
@@ -256,7 +255,7 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
if (!isValidProtocolString(protocols[i])) {
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Wrong protocol for WebSocket '" + encodeProtocolString(protocols[i]) + "'");
m_state = CLOSED;
- es.throwDOMException(SyntaxError);
+ ec = SyntaxError;
return;
}
}
@@ -265,7 +264,7 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
if (!visited.add(protocols[i]).isNewEntry) {
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "WebSocket protocols contain duplicates: '" + encodeProtocolString(protocols[i]) + "'");
m_state = CLOSED;
- es.throwDOMException(SyntaxError);
+ ec = SyntaxError;
return;
}
}
@@ -278,12 +277,12 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
ActiveDOMObject::setPendingActivity(this);
}
-void WebSocket::handleSendResult(WebSocketChannel::SendResult result, ExceptionState& es)
+void WebSocket::handleSendResult(WebSocketChannel::SendResult result, ExceptionCode& ec)
{
switch (result) {
case WebSocketChannel::InvalidMessage:
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "WebSocket message contains invalid character(s).");
- es.throwDOMException(SyntaxError);
+ ec = SyntaxError;
return;
case WebSocketChannel::SendFail:
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "WebSocket send() failed.");
@@ -302,11 +301,11 @@ void WebSocket::updateBufferedAmountAfterClose(unsigned long payloadSize)
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "WebSocket is already in CLOSING or CLOSED state.");
}
-void WebSocket::send(const String& message, ExceptionState& es)
+void WebSocket::send(const String& message, ExceptionCode& ec)
{
LOG(Network, "WebSocket %p send() Sending String '%s'", this, message.utf8().data());
if (m_state == CONNECTING) {
- es.throwDOMException(InvalidStateError);
+ ec = InvalidStateError;
return;
}
// No exception is raised if the connection was once established but has subsequently been closed.
@@ -315,15 +314,15 @@ void WebSocket::send(const String& message, ExceptionState& es)
return;
}
ASSERT(m_channel);
- handleSendResult(m_channel->send(message), es);
+ handleSendResult(m_channel->send(message), ec);
}
-void WebSocket::send(ArrayBuffer* binaryData, ExceptionState& es)
+void WebSocket::send(ArrayBuffer* binaryData, ExceptionCode& ec)
{
LOG(Network, "WebSocket %p send() Sending ArrayBuffer %p", this, binaryData);
ASSERT(binaryData);
if (m_state == CONNECTING) {
- es.throwDOMException(InvalidStateError);
+ ec = InvalidStateError;
return;
}
if (m_state == CLOSING || m_state == CLOSED) {
@@ -331,15 +330,15 @@ void WebSocket::send(ArrayBuffer* binaryData, ExceptionState& es)
return;
}
ASSERT(m_channel);
- handleSendResult(m_channel->send(*binaryData, 0, binaryData->byteLength()), es);
+ handleSendResult(m_channel->send(*binaryData, 0, binaryData->byteLength()), ec);
}
-void WebSocket::send(ArrayBufferView* arrayBufferView, ExceptionState& es)
+void WebSocket::send(ArrayBufferView* arrayBufferView, ExceptionCode& ec)
{
LOG(Network, "WebSocket %p send() Sending ArrayBufferView %p", this, arrayBufferView);
ASSERT(arrayBufferView);
if (m_state == CONNECTING) {
- es.throwDOMException(InvalidStateError);
+ ec = InvalidStateError;
return;
}
if (m_state == CLOSING || m_state == CLOSED) {
@@ -348,15 +347,15 @@ void WebSocket::send(ArrayBufferView* arrayBufferView, ExceptionState& es)
}
ASSERT(m_channel);
RefPtr<ArrayBuffer> arrayBuffer(arrayBufferView->buffer());
- handleSendResult(m_channel->send(*arrayBuffer, arrayBufferView->byteOffset(), arrayBufferView->byteLength()), es);
+ handleSendResult(m_channel->send(*arrayBuffer, arrayBufferView->byteOffset(), arrayBufferView->byteLength()), ec);
}
-void WebSocket::send(Blob* binaryData, ExceptionState& es)
+void WebSocket::send(Blob* binaryData, ExceptionCode& ec)
{
LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->url().elidedString().utf8().data());
ASSERT(binaryData);
if (m_state == CONNECTING) {
- es.throwDOMException(InvalidStateError);
+ ec = InvalidStateError;
return;
}
if (m_state == CLOSING || m_state == CLOSED) {
@@ -364,38 +363,38 @@ void WebSocket::send(Blob* binaryData, ExceptionState& es)
return;
}
ASSERT(m_channel);
- handleSendResult(m_channel->send(*binaryData), es);
+ handleSendResult(m_channel->send(*binaryData), ec);
}
-void WebSocket::close(unsigned short code, const String& reason, ExceptionState& es)
+void WebSocket::close(unsigned short code, const String& reason, ExceptionCode& ec)
{
- closeInternal(code, reason, es);
+ closeInternal(code, reason, ec);
}
-void WebSocket::close(ExceptionState& es)
+void WebSocket::close(ExceptionCode& ec)
{
- closeInternal(WebSocketChannel::CloseEventCodeNotSpecified, String(), es);
+ closeInternal(WebSocketChannel::CloseEventCodeNotSpecified, String(), ec);
}
-void WebSocket::close(unsigned short code, ExceptionState& es)
+void WebSocket::close(unsigned short code, ExceptionCode& ec)
{
- closeInternal(code, String(), es);
+ closeInternal(code, String(), ec);
}
-void WebSocket::closeInternal(int code, const String& reason, ExceptionState& es)
+void WebSocket::closeInternal(int code, const String& reason, ExceptionCode& ec)
{
if (code == WebSocketChannel::CloseEventCodeNotSpecified)
LOG(Network, "WebSocket %p close() without code and reason", this);
else {
LOG(Network, "WebSocket %p close() code=%d reason='%s'", this, code, reason.utf8().data());
if (!(code == WebSocketChannel::CloseEventCodeNormalClosure || (WebSocketChannel::CloseEventCodeMinimumUserDefined <= code && code <= WebSocketChannel::CloseEventCodeMaximumUserDefined))) {
- es.throwDOMException(InvalidAccessError);
+ ec = InvalidAccessError;
return;
}
CString utf8 = reason.utf8(String::StrictConversionReplacingUnpairedSurrogatesWithFFFD);
if (utf8.length() > maxReasonSizeInBytes) {
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "WebSocket close message is too long.");
- es.throwDOMException(SyntaxError);
+ ec = SyntaxError;
return;
}
}
« no previous file with comments | « Source/modules/websockets/WebSocket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698