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

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

Issue 954933003: Sync the WebSocket interface with the spec (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add TypeChecking=Interface Created 5 years, 10 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/DOMWebSocket.h ('k') | Source/modules/websockets/DocumentWebSocketChannel.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/websockets/DOMWebSocket.cpp
diff --git a/Source/modules/websockets/DOMWebSocket.cpp b/Source/modules/websockets/DOMWebSocket.cpp
index 3931e978fb0781cc10a17ff5953f30ba473e211b..e821d6ac98266584b11026ea1270b66770bbe9a2 100644
--- a/Source/modules/websockets/DOMWebSocket.cpp
+++ b/Source/modules/websockets/DOMWebSocket.cpp
@@ -33,6 +33,7 @@
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptController.h"
+#include "bindings/modules/v8/UnionTypesModules.h"
#include "core/dom/DOMArrayBuffer.h"
#include "core/dom/DOMArrayBufferView.h"
#include "core/dom/Document.h"
@@ -242,11 +243,11 @@ void DOMWebSocket::logError(const String& message)
DOMWebSocket* DOMWebSocket::create(ExecutionContext* context, const String& url, ExceptionState& exceptionState)
{
- Vector<String> protocols;
+ StringOrStringSequence protocols;
return create(context, url, protocols, exceptionState);
}
-DOMWebSocket* DOMWebSocket::create(ExecutionContext* context, const String& url, const Vector<String>& protocols, ExceptionState& exceptionState)
+DOMWebSocket* DOMWebSocket::create(ExecutionContext* context, const String& url, const StringOrStringSequence& protocols, ExceptionState& exceptionState)
{
if (url.isNull()) {
exceptionState.throwDOMException(SyntaxError, "Failed to create a WebSocket: the provided URL is invalid.");
@@ -256,20 +257,24 @@ DOMWebSocket* DOMWebSocket::create(ExecutionContext* context, const String& url,
DOMWebSocket* webSocket = new DOMWebSocket(context);
webSocket->suspendIfNeeded();
- webSocket->connect(url, protocols, exceptionState);
+ if (protocols.isNull()) {
+ Vector<String> protocolsVector;
+ webSocket->connect(url, protocolsVector, exceptionState);
+ } else if (protocols.isString()) {
+ Vector<String> protocolsVector;
+ protocolsVector.append(protocols.getAsString());
+ webSocket->connect(url, protocolsVector, exceptionState);
+ } else {
+ ASSERT(protocols.isStringSequence());
+ webSocket->connect(url, protocols.getAsStringSequence(), exceptionState);
+ }
+
if (exceptionState.hadException())
return nullptr;
return webSocket;
}
-DOMWebSocket* DOMWebSocket::create(ExecutionContext* context, const String& url, const String& protocol, ExceptionState& exceptionState)
-{
- Vector<String> protocols;
- protocols.append(protocol);
- return create(context, url, protocols, exceptionState);
-}
-
void DOMWebSocket::connect(const String& url, const Vector<String>& protocols, ExceptionState& exceptionState)
{
@@ -468,7 +473,8 @@ void DOMWebSocket::closeInternal(int code, const String& reason, ExceptionState&
exceptionState.throwDOMException(InvalidAccessError, "The code must be either 1000, or between 3000 and 4999. " + String::number(code) + " is neither.");
return;
}
- CString utf8 = reason.utf8(StrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD);
+ // Bindings specify USVString, so unpaired surrogates are already replaced with U+FFFD.
+ CString utf8 = reason.utf8();
if (utf8.length() > maxReasonSizeInBytes) {
exceptionState.throwDOMException(SyntaxError, "The message must not be greater than " + String::number(maxReasonSizeInBytes) + " bytes.");
return;
« no previous file with comments | « Source/modules/websockets/DOMWebSocket.h ('k') | Source/modules/websockets/DocumentWebSocketChannel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698