Commit 8812aabd authored by yutak@chromium.org's avatar yutak@chromium.org

WebSocket: Pass the value of useHixie76Protocol flag to WebSocket object

https://bugs.webkit.org/show_bug.cgi?id=65250

Reviewed by Alexey Proskuryakov.

Add useHixie76Protocol() method to WebSocketChannel and its family. To implement hybi-specific
attributes in WebSocket object, WebSocket class needs to be able to get the value of
useHixie76Protocol flag of WebSocketChannel.

If the WebSocket object is created in a worker thread, the flag value must be obtained from
WebSocketChannel which resides in the loader thread (through WorkerThreadableWebSocketChannel).
Since the value does not change after creation of WebSocketChannel, it can be cached in
the worker thread.

There is no change in behavior, thus no new tests.

* websockets/ThreadableWebSocketChannel.h:
* websockets/ThreadableWebSocketChannelClientWrapper.cpp:
(WebCore::ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper):
(WebCore::ThreadableWebSocketChannelClientWrapper::useHixie76Protocol):
(WebCore::ThreadableWebSocketChannelClientWrapper::setUseHixie76Protocol):
* websockets/ThreadableWebSocketChannelClientWrapper.h:
* websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::useHixie76Protocol):
* websockets/WebSocketChannel.h:
* websockets/WorkerThreadableWebSocketChannel.cpp:
(WebCore::WorkerThreadableWebSocketChannel::useHixie76Protocol):
(WebCore::WorkerThreadableWebSocketChannel::Peer::useHixie76Protocol):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel):
* websockets/WorkerThreadableWebSocketChannel.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@91919 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 55d40f75
2011-07-28 Yuta Kitamura <yutak@chromium.org>
WebSocket: Pass the value of useHixie76Protocol flag to WebSocket object
https://bugs.webkit.org/show_bug.cgi?id=65250
Reviewed by Alexey Proskuryakov.
Add useHixie76Protocol() method to WebSocketChannel and its family. To implement hybi-specific
attributes in WebSocket object, WebSocket class needs to be able to get the value of
useHixie76Protocol flag of WebSocketChannel.
If the WebSocket object is created in a worker thread, the flag value must be obtained from
WebSocketChannel which resides in the loader thread (through WorkerThreadableWebSocketChannel).
Since the value does not change after creation of WebSocketChannel, it can be cached in
the worker thread.
There is no change in behavior, thus no new tests.
* websockets/ThreadableWebSocketChannel.h:
* websockets/ThreadableWebSocketChannelClientWrapper.cpp:
(WebCore::ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper):
(WebCore::ThreadableWebSocketChannelClientWrapper::useHixie76Protocol):
(WebCore::ThreadableWebSocketChannelClientWrapper::setUseHixie76Protocol):
* websockets/ThreadableWebSocketChannelClientWrapper.h:
* websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::useHixie76Protocol):
* websockets/WebSocketChannel.h:
* websockets/WorkerThreadableWebSocketChannel.cpp:
(WebCore::WorkerThreadableWebSocketChannel::useHixie76Protocol):
(WebCore::WorkerThreadableWebSocketChannel::Peer::useHixie76Protocol):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel):
(WebCore::WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel):
* websockets/WorkerThreadableWebSocketChannel.h:
2011-07-28 Rob Buis <rbuis@rim.com>
REGRESSION (r91125): Google Drawings is broken
......@@ -49,6 +49,7 @@ public:
ThreadableWebSocketChannel() { }
static PassRefPtr<ThreadableWebSocketChannel> create(ScriptExecutionContext*, WebSocketChannelClient*, const KURL&, const String& protocol);
virtual bool useHixie76Protocol() = 0;
virtual void connect() = 0;
virtual bool send(const String& message) = 0;
virtual unsigned long bufferedAmount() const = 0;
......
......@@ -43,6 +43,7 @@ namespace WebCore {
ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper(WebSocketChannelClient* client)
: m_client(client)
, m_syncMethodDone(false)
, m_useHixie76Protocol(true)
, m_sent(false)
, m_bufferedAmount(0)
, m_suspended(false)
......@@ -69,6 +70,16 @@ bool ThreadableWebSocketChannelClientWrapper::syncMethodDone() const
return m_syncMethodDone;
}
bool ThreadableWebSocketChannelClientWrapper::useHixie76Protocol() const
{
return m_useHixie76Protocol;
}
void ThreadableWebSocketChannelClientWrapper::setUseHixie76Protocol(bool useHixie76Protocol)
{
m_useHixie76Protocol = useHixie76Protocol;
}
bool ThreadableWebSocketChannelClientWrapper::sent() const
{
return m_sent;
......
......@@ -53,6 +53,11 @@ public:
void setSyncMethodDone();
bool syncMethodDone() const;
// The value of useHixie76Protocol flag is cachable; this value is saved after WebSocketChannel (on the main
// thread) is constructed.
bool useHixie76Protocol() const;
void setUseHixie76Protocol(bool);
bool sent() const;
void setSent(bool);
......@@ -80,6 +85,7 @@ protected:
WebSocketChannelClient* m_client;
bool m_syncMethodDone;
bool m_useHixie76Protocol;
bool m_sent;
unsigned long m_bufferedAmount;
bool m_suspended;
......
......@@ -116,6 +116,11 @@ WebSocketChannel::~WebSocketChannel()
fastFree(m_buffer);
}
bool WebSocketChannel::useHixie76Protocol()
{
return m_useHixie76Protocol;
}
void WebSocketChannel::connect()
{
LOG(Network, "WebSocketChannel %p connect", this);
......
......@@ -54,6 +54,7 @@ namespace WebCore {
static PassRefPtr<WebSocketChannel> create(ScriptExecutionContext* context, WebSocketChannelClient* client, const KURL& url, const String& protocol) { return adoptRef(new WebSocketChannel(context, client, url, protocol)); }
virtual ~WebSocketChannel();
virtual bool useHixie76Protocol();
virtual void connect();
virtual bool send(const String& message);
virtual unsigned long bufferedAmount() const;
......
......@@ -62,6 +62,12 @@ WorkerThreadableWebSocketChannel::~WorkerThreadableWebSocketChannel()
m_bridge->disconnect();
}
bool WorkerThreadableWebSocketChannel::useHixie76Protocol()
{
ASSERT(m_workerClientWrapper);
return m_workerClientWrapper->useHixie76Protocol();
}
void WorkerThreadableWebSocketChannel::connect()
{
if (m_bridge)
......@@ -130,6 +136,13 @@ WorkerThreadableWebSocketChannel::Peer::~Peer()
m_mainWebSocketChannel->disconnect();
}
bool WorkerThreadableWebSocketChannel::Peer::useHixie76Protocol()
{
ASSERT(isMainThread());
ASSERT(m_mainWebSocketChannel);
return m_mainWebSocketChannel->useHixie76Protocol();
}
void WorkerThreadableWebSocketChannel::Peer::connect()
{
ASSERT(isMainThread());
......@@ -258,10 +271,11 @@ void WorkerThreadableWebSocketChannel::Peer::didClose(unsigned long unhandledBuf
m_loaderProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidClose, m_workerClientWrapper, unhandledBufferedAmount, closingHandshakeCompletion), m_taskMode);
}
void WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel(ScriptExecutionContext* context, Bridge* thisPtr, Peer* peer, PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper)
void WorkerThreadableWebSocketChannel::Bridge::setWebSocketChannel(ScriptExecutionContext* context, Bridge* thisPtr, Peer* peer, PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, bool useHixie76Protocol)
{
ASSERT_UNUSED(context, context->isWorkerContext());
thisPtr->m_peer = peer;
workerClientWrapper->setUseHixie76Protocol(useHixie76Protocol);
workerClientWrapper->setSyncMethodDone();
}
......@@ -276,7 +290,7 @@ void WorkerThreadableWebSocketChannel::Bridge::mainThreadCreateWebSocketChannel(
thisPtr->m_loaderProxy.postTaskForModeToWorkerContext(
createCallbackTask(&Bridge::setWebSocketChannel,
AllowCrossThreadAccess(thisPtr),
AllowCrossThreadAccess(peer), clientWrapper), taskMode);
AllowCrossThreadAccess(peer), clientWrapper, peer->useHixie76Protocol()), taskMode);
}
WorkerThreadableWebSocketChannel::Bridge::Bridge(PassRefPtr<ThreadableWebSocketChannelClientWrapper> workerClientWrapper, PassRefPtr<WorkerContext> workerContext, const String& taskMode, const KURL& url, const String& protocol)
......
......@@ -60,6 +60,7 @@ public:
}
virtual ~WorkerThreadableWebSocketChannel();
virtual bool useHixie76Protocol();
virtual void connect();
virtual bool send(const String& message);
virtual unsigned long bufferedAmount() const;
......@@ -88,6 +89,7 @@ private:
}
~Peer();
bool useHixie76Protocol();
void connect();
void send(const String& message);
void bufferedAmount();
......@@ -134,7 +136,7 @@ private:
private:
Bridge(PassRefPtr<ThreadableWebSocketChannelClientWrapper>, PassRefPtr<WorkerContext>, const String& taskMode, const KURL&, const String& protocol);
static void setWebSocketChannel(ScriptExecutionContext*, Bridge* thisPtr, Peer*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
static void setWebSocketChannel(ScriptExecutionContext*, Bridge* thisPtr, Peer*, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, bool useHixie76Protocol);
// Executed on the main thread to create a Peer for this bridge.
static void mainThreadCreateWebSocketChannel(ScriptExecutionContext*, Bridge* thisPtr, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, const String& taskMode, const KURL&, const String& protocol);
......
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