Commit 9ac0ede4 authored by yhirano@chromium.org's avatar yhirano@chromium.org

[WebSocket] Make subprotocol and extensions live in WebSocket

Currently WebSocketChannel has methods subprotocol and extensions.
But they can be available only after the connection is established and
they don't change once set. Futhermore, there is didConnect notification
in WebSocketChannelClient.
This CL removes subprotocol and extensions from WebSocketChannel and
add them as WebSocketChannelClient::didConnect parameters.

BUG=384238
R=tyoshino

Review URL: https://codereview.chromium.org/334873002

git-svn-id: svn://svn.chromium.org/blink/trunk@176115 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0b144341
......@@ -124,28 +124,6 @@ bool MainThreadWebSocketChannel::connect(const KURL& url, const String& protocol
return true;
}
String MainThreadWebSocketChannel::subprotocol()
{
WTF_LOG(Network, "MainThreadWebSocketChannel %p subprotocol()", this);
if (!m_handshake || m_handshake->mode() != WebSocketHandshake::Connected)
return "";
String serverProtocol = m_handshake->serverWebSocketProtocol();
if (serverProtocol.isNull())
return "";
return serverProtocol;
}
String MainThreadWebSocketChannel::extensions()
{
WTF_LOG(Network, "MainThreadWebSocketChannel %p extensions()", this);
if (!m_handshake || m_handshake->mode() != WebSocketHandshake::Connected)
return "";
String extensions = m_handshake->acceptedExtensions();
if (extensions.isNull())
return "";
return extensions;
}
WebSocketChannel::SendResult MainThreadWebSocketChannel::send(const String& message)
{
WTF_LOG(Network, "MainThreadWebSocketChannel %p send() Sending String '%s'", this, message.utf8().data());
......@@ -484,7 +462,9 @@ bool MainThreadWebSocketChannel::processOneItemFromBuffer()
WTF_LOG(Network, "MainThreadWebSocketChannel %p Connected", this);
skipBuffer(headerLength);
m_client->didConnect();
String subprotocol = m_handshake->serverWebSocketProtocol();
String extensions = m_handshake->acceptedExtensions();
m_client->didConnect(subprotocol.isNull() ? "" : subprotocol, extensions.isNull() ? "" : extensions);
WTF_LOG(Network, "MainThreadWebSocketChannel %p %lu bytes remaining in m_buffer", this, static_cast<unsigned long>(m_buffer.size()));
return !m_buffer.isEmpty();
}
......
......@@ -71,8 +71,6 @@ public:
// WebSocketChannel functions.
virtual bool connect(const KURL&, const String& protocol) OVERRIDE;
virtual String subprotocol() OVERRIDE;
virtual String extensions() OVERRIDE;
virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE;
virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLength) OVERRIDE;
virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRIDE;
......
......@@ -170,18 +170,6 @@ bool NewWebSocketChannelImpl::connect(const KURL& url, const String& protocol)
return true;
}
String NewWebSocketChannelImpl::subprotocol()
{
WTF_LOG(Network, "NewWebSocketChannelImpl %p subprotocol()", this);
return m_subprotocol;
}
String NewWebSocketChannelImpl::extensions()
{
WTF_LOG(Network, "NewWebSocketChannelImpl %p extensions()", this);
return m_extensions;
}
WebSocketChannel::SendResult NewWebSocketChannelImpl::send(const String& message)
{
WTF_LOG(Network, "NewWebSocketChannelImpl %p sendText(%s)", this, message.utf8().data());
......@@ -418,9 +406,7 @@ void NewWebSocketChannelImpl::didConnect(WebSocketHandle* handle, bool fail, con
// failAsError may delete this object.
return;
}
m_subprotocol = selectedProtocol;
m_extensions = extensions;
m_client->didConnect();
m_client->didConnect(selectedProtocol, extensions);
}
void NewWebSocketChannelImpl::didStartOpeningHandshake(WebSocketHandle* handle, const blink::WebSocketHandshakeRequestInfo& request)
......
......@@ -78,8 +78,6 @@ public:
// WebSocketChannel functions.
virtual bool connect(const KURL&, const String& protocol) OVERRIDE;
virtual String subprotocol() OVERRIDE;
virtual String extensions() OVERRIDE;
virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE;
virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLength) OVERRIDE;
virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRIDE;
......@@ -170,8 +168,6 @@ private:
int64_t m_receivedDataSizeForFlowControl;
unsigned long m_bufferedAmount;
size_t m_sentSizeOfTopMessage;
String m_subprotocol;
String m_extensions;
String m_sourceURLAtConstruction;
unsigned m_lineNumberAtConstruction;
......
......@@ -54,40 +54,14 @@ PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> ThreadableWebSoc
return adoptRefWillBeNoop(new ThreadableWebSocketChannelClientWrapper(client));
}
String ThreadableWebSocketChannelClientWrapper::subprotocol() const
{
if (m_subprotocol.isEmpty())
return emptyString();
return String(m_subprotocol);
}
void ThreadableWebSocketChannelClientWrapper::setSubprotocol(const String& subprotocol)
{
m_subprotocol.clear();
append(m_subprotocol, subprotocol);
}
String ThreadableWebSocketChannelClientWrapper::extensions() const
{
if (m_extensions.isEmpty())
return emptyString();
return String(m_extensions);
}
void ThreadableWebSocketChannelClientWrapper::setExtensions(const String& extensions)
{
m_extensions.clear();
append(m_extensions, extensions);
}
void ThreadableWebSocketChannelClientWrapper::clearClient()
{
m_client = 0;
}
void ThreadableWebSocketChannelClientWrapper::didConnect()
void ThreadableWebSocketChannelClientWrapper::didConnect(const String& subprotocol, const String& extensions)
{
m_pendingTasks.append(createCallbackTask(&didConnectCallback, this));
m_pendingTasks.append(createCallbackTask(&didConnectCallback, this, subprotocol, extensions));
if (!m_suspended)
processPendingTasks();
}
......@@ -155,11 +129,11 @@ void ThreadableWebSocketChannelClientWrapper::processPendingTasks()
(*iter)->performTask(0);
}
void ThreadableWebSocketChannelClientWrapper::didConnectCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper)
void ThreadableWebSocketChannelClientWrapper::didConnectCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper, const String& subprotocol, const String& extensions)
{
ASSERT_UNUSED(context, !context);
if (wrapper->m_client)
wrapper->m_client->didConnect();
wrapper->m_client->didConnect(subprotocol, extensions);
}
void ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrapper, const String& message)
......
......@@ -50,15 +50,9 @@ public:
static PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> create(WebSocketChannelClient*);
~ThreadableWebSocketChannelClientWrapper();
// Subprotocol and extensions will be available when didConnect() callback is invoked.
String subprotocol() const;
void setSubprotocol(const String&);
String extensions() const;
void setExtensions(const String&);
void clearClient();
void didConnect();
void didConnect(const String& subprotocol, const String& extensions);
void didReceiveMessage(const String& message);
void didReceiveBinaryData(PassOwnPtr<Vector<char> >);
void didUpdateBufferedAmount(unsigned long bufferedAmount);
......@@ -76,7 +70,7 @@ private:
void processPendingTasks();
static void didConnectCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>);
static void didConnectCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, const String& subprotocol, const String& extensions);
static void didReceiveMessageCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, const String& message);
static void didReceiveBinaryDataCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char> >);
static void didUpdateBufferedAmountCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long bufferedAmount);
......@@ -85,9 +79,6 @@ private:
static void didReceiveMessageErrorCallback(ExecutionContext*, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper>);
WebSocketChannelClient* m_client;
// ThreadSafeRefCounted must not have String member variables.
Vector<UChar> m_subprotocol;
Vector<UChar> m_extensions;
bool m_suspended;
Vector<OwnPtr<ExecutionContextTask> > m_pendingTasks;
};
......
......@@ -585,14 +585,14 @@ void WebSocket::stop()
m_state = CLOSED;
}
void WebSocket::didConnect()
void WebSocket::didConnect(const String& subprotocol, const String& extensions)
{
WTF_LOG(Network, "WebSocket %p didConnect()", this);
if (m_state != CONNECTING)
return;
m_state = OPEN;
m_subprotocol = m_channel->subprotocol();
m_extensions = m_channel->extensions();
m_subprotocol = subprotocol;
m_extensions = extensions;
m_eventQueue->dispatch(Event::create(EventTypeNames::open));
}
......
......@@ -116,7 +116,7 @@ public:
virtual void stop() OVERRIDE;
// WebSocketChannelClient functions.
virtual void didConnect() OVERRIDE;
virtual void didConnect(const String& subprotocol, const String& extensions) OVERRIDE;
virtual void didReceiveMessage(const String& message) OVERRIDE;
virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE;
virtual void didReceiveMessageError() OVERRIDE;
......
......@@ -81,8 +81,6 @@ public:
};
virtual bool connect(const KURL&, const String& protocol) = 0;
virtual String subprotocol() = 0; // Will be available after didConnect() callback is invoked.
virtual String extensions() = 0; // Will be available after didConnect() callback is invoked.
virtual SendResult send(const String& message) = 0;
virtual SendResult send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLength) = 0;
virtual SendResult send(PassRefPtr<BlobDataHandle>) = 0;
......
......@@ -40,7 +40,7 @@ namespace WebCore {
class WebSocketChannelClient {
public:
virtual ~WebSocketChannelClient() { }
virtual void didConnect() { }
virtual void didConnect(const String& subprotocol, const String& extensions) { }
virtual void didReceiveMessage(const String&) { }
virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) { }
virtual void didReceiveMessageError() { }
......
......@@ -46,8 +46,6 @@ public:
}
MOCK_METHOD2(connect, bool(const KURL&, const String&));
MOCK_METHOD0(subprotocol, String());
MOCK_METHOD0(extensions, String());
MOCK_METHOD1(send, SendResult(const String&));
MOCK_METHOD3(send, SendResult(const ArrayBuffer&, unsigned, unsigned));
MOCK_METHOD1(send, SendResult(PassRefPtr<BlobDataHandle>));
......@@ -271,15 +269,13 @@ TEST_F(WebSocketTest, connectSuccess)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String("aa, bb"))).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String("bb")));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String("cc")));
}
m_websocket->connect("ws://example.com/", subprotocols, m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
EXPECT_EQ(WebSocket::CONNECTING, m_websocket->readyState());
m_websocket->didConnect();
m_websocket->didConnect("bb", "cc");
EXPECT_EQ(WebSocket::OPEN, m_websocket->readyState());
EXPECT_EQ("bb", m_websocket->protocol());
......@@ -369,8 +365,6 @@ TEST_F(WebSocketTest, close)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), close(3005, String("bye")));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
......@@ -378,7 +372,7 @@ TEST_F(WebSocketTest, close)
EXPECT_FALSE(m_exceptionState.hadException());
EXPECT_EQ(WebSocket::CONNECTING, m_websocket->readyState());
m_websocket->didConnect();
m_websocket->didConnect("", "");
EXPECT_EQ(WebSocket::OPEN, m_websocket->readyState());
m_websocket->close(3005, "bye", m_exceptionState);
......@@ -391,8 +385,6 @@ TEST_F(WebSocketTest, closeWithoutReason)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), close(3005, String()));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
......@@ -400,7 +392,7 @@ TEST_F(WebSocketTest, closeWithoutReason)
EXPECT_FALSE(m_exceptionState.hadException());
EXPECT_EQ(WebSocket::CONNECTING, m_websocket->readyState());
m_websocket->didConnect();
m_websocket->didConnect("", "");
EXPECT_EQ(WebSocket::OPEN, m_websocket->readyState());
m_websocket->close(3005, m_exceptionState);
......@@ -413,8 +405,6 @@ TEST_F(WebSocketTest, closeWithoutCodeAndReason)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), close(-1, String()));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
......@@ -422,7 +412,7 @@ TEST_F(WebSocketTest, closeWithoutCodeAndReason)
EXPECT_FALSE(m_exceptionState.hadException());
EXPECT_EQ(WebSocket::CONNECTING, m_websocket->readyState());
m_websocket->didConnect();
m_websocket->didConnect("", "");
EXPECT_EQ(WebSocket::OPEN, m_websocket->readyState());
m_websocket->close(m_exceptionState);
......@@ -435,8 +425,6 @@ TEST_F(WebSocketTest, closeWhenClosing)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), close(-1, String()));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
......@@ -444,7 +432,7 @@ TEST_F(WebSocketTest, closeWhenClosing)
EXPECT_FALSE(m_exceptionState.hadException());
EXPECT_EQ(WebSocket::CONNECTING, m_websocket->readyState());
m_websocket->didConnect();
m_websocket->didConnect("", "");
EXPECT_EQ(WebSocket::OPEN, m_websocket->readyState());
m_websocket->close(m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
......@@ -461,8 +449,6 @@ TEST_F(WebSocketTest, closeWhenClosed)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), close(-1, String()));
EXPECT_CALL(channel(), disconnect());
}
......@@ -471,7 +457,7 @@ TEST_F(WebSocketTest, closeWhenClosed)
EXPECT_FALSE(m_exceptionState.hadException());
EXPECT_EQ(WebSocket::CONNECTING, m_websocket->readyState());
m_websocket->didConnect();
m_websocket->didConnect("", "");
EXPECT_EQ(WebSocket::OPEN, m_websocket->readyState());
m_websocket->close(m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
......@@ -551,15 +537,13 @@ TEST_F(WebSocketTest, sendStringSuccess)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), send(String("hello"))).WillOnce(Return(WebSocketChannel::SendSuccess));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
m_websocket->didConnect();
m_websocket->didConnect("", "");
m_websocket->send("hello", m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
......@@ -571,15 +555,13 @@ TEST_F(WebSocketTest, sendStringFail)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), send(String("hello"))).WillOnce(Return(WebSocketChannel::SendFail));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
m_websocket->didConnect();
m_websocket->didConnect("", "");
m_websocket->send("hello", m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
......@@ -591,15 +573,13 @@ TEST_F(WebSocketTest, sendStringInvalidMessage)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), send(String("hello"))).WillOnce(Return(WebSocketChannel::InvalidMessage));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
m_websocket->didConnect();
m_websocket->didConnect("", "");
m_websocket->send("hello", m_exceptionState);
EXPECT_TRUE(m_exceptionState.hadException());
......@@ -677,15 +657,13 @@ TEST_F(WebSocketTest, sendArrayBufferSuccess)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), send(Ref(*view->buffer()), 0, 8)).WillOnce(Return(WebSocketChannel::SendSuccess));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
m_websocket->didConnect();
m_websocket->didConnect("", "");
m_websocket->send(view->buffer().get(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
......@@ -698,15 +676,13 @@ TEST_F(WebSocketTest, sendArrayBufferFail)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), send(Ref(*view->buffer()), 0, 8)).WillOnce(Return(WebSocketChannel::SendFail));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
m_websocket->didConnect();
m_websocket->didConnect("", "");
m_websocket->send(view->buffer().get(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
......@@ -719,15 +695,13 @@ TEST_F(WebSocketTest, sendArrayBufferInvalidMessage)
{
InSequence s;
EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String())).WillOnce(Return(true));
EXPECT_CALL(channel(), subprotocol()).WillOnce(Return(String()));
EXPECT_CALL(channel(), extensions()).WillOnce(Return(String()));
EXPECT_CALL(channel(), send(Ref(*view->buffer()), 0, 8)).WillOnce(Return(WebSocketChannel::InvalidMessage));
}
m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState);
EXPECT_FALSE(m_exceptionState.hadException());
m_websocket->didConnect();
m_websocket->didConnect("", "");
m_websocket->send(view->buffer().get(), m_exceptionState);
EXPECT_TRUE(m_exceptionState.hadException());
......
......@@ -143,16 +143,6 @@ bool WorkerThreadableWebSocketChannel::connect(const KURL& url, const String& pr
return false;
}
String WorkerThreadableWebSocketChannel::subprotocol()
{
return m_workerClientWrapper->subprotocol();
}
String WorkerThreadableWebSocketChannel::extensions()
{
return m_workerClientWrapper->extensions();
}
WebSocketChannel::SendResult WorkerThreadableWebSocketChannel::send(const String& message)
{
if (!m_bridge)
......@@ -377,15 +367,13 @@ void WorkerThreadableWebSocketChannel::Peer::resume()
static void workerGlobalScopeDidConnect(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const String& subprotocol, const String& extensions)
{
ASSERT_UNUSED(context, context->isWorkerGlobalScope());
workerClientWrapper->setSubprotocol(subprotocol);
workerClientWrapper->setExtensions(extensions);
workerClientWrapper->didConnect();
workerClientWrapper->didConnect(subprotocol, extensions);
}
void WorkerThreadableWebSocketChannel::Peer::didConnect()
void WorkerThreadableWebSocketChannel::Peer::didConnect(const String& subprotocol, const String& extensions)
{
ASSERT(isMainThread());
m_loaderProxy.postTaskToWorkerGlobalScope(createCallbackTask(&workerGlobalScopeDidConnect, m_workerClientWrapper.get(), m_mainWebSocketChannel->subprotocol(), m_mainWebSocketChannel->extensions()));
m_loaderProxy.postTaskToWorkerGlobalScope(createCallbackTask(&workerGlobalScopeDidConnect, m_workerClientWrapper.get(), subprotocol, extensions));
}
static void workerGlobalScopeDidReceiveMessage(ExecutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, const String& message)
......
......@@ -73,8 +73,6 @@ public:
// WebSocketChannel functions.
virtual bool connect(const KURL&, const String& protocol) OVERRIDE;
virtual String subprotocol() OVERRIDE;
virtual String extensions() OVERRIDE;
virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE;
virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLength) OVERRIDE;
virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRIDE;
......@@ -117,7 +115,7 @@ public:
void resume();
// WebSocketChannelClient functions.
virtual void didConnect() OVERRIDE;
virtual void didConnect(const String& subprotocol, const String& extensions) OVERRIDE;
virtual void didReceiveMessage(const String& message) OVERRIDE;
virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE;
virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE;
......
......@@ -85,12 +85,12 @@ void WebSocketImpl::connect(const WebURL& url, const WebString& protocol)
WebString WebSocketImpl::subprotocol()
{
return m_private->subprotocol();
return m_subprotocol;
}
WebString WebSocketImpl::extensions()
{
return m_private->extensions();
return m_extensions;
}
bool WebSocketImpl::sendText(const WebString& message)
......@@ -124,8 +124,10 @@ void WebSocketImpl::disconnect()
m_client = 0;
}
void WebSocketImpl::didConnect()
void WebSocketImpl::didConnect(const String& subprotocol, const String& extensions)
{
m_subprotocol = subprotocol;
m_extensions = extensions;
m_client->didConnect();
}
......
......@@ -34,6 +34,7 @@
#include "modules/websockets/WebSocketChannelClient.h"
#include "platform/heap/Handle.h"
#include "public/platform/WebCommon.h"
#include "public/platform/WebString.h"
#include "public/web/WebSocket.h"
#include "public/web/WebSocketClient.h"
#include "wtf/OwnPtr.h"
......@@ -44,7 +45,6 @@ namespace WebCore { class WebSocketChannel; }
namespace blink {
class WebDocument;
class WebString;
class WebURL;
class WebSocketImpl FINAL : public WebSocket, public WebCore::WebSocketChannelClient {
......@@ -67,7 +67,7 @@ public:
virtual void disconnect() OVERRIDE;
// WebSocketChannelClient
virtual void didConnect() OVERRIDE;
virtual void didConnect(const String& subprotocol, const String& extensions) OVERRIDE;
virtual void didReceiveMessage(const String& message) OVERRIDE;
virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) OVERRIDE;
virtual void didReceiveMessageError() OVERRIDE;
......@@ -79,6 +79,8 @@ private:
RefPtrWillBePersistent<WebCore::WebSocketChannel> m_private;
WebSocketClient* m_client;
BinaryType m_binaryType;
WebString m_subprotocol;
WebString m_extensions;
};
} // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment