ThreadableWebSocketChannelClientWrapper.h [plain text]
#ifndef ThreadableWebSocketChannelClientWrapper_h
#define ThreadableWebSocketChannelClientWrapper_h
#if ENABLE(WEB_SOCKETS)
#include "ScriptExecutionContext.h"
#include "ThreadableWebSocketChannel.h"
#include "WebSocketChannelClient.h"
#include "WorkerThreadableWebSocketChannel.h"
#include <memory>
#include <wtf/Forward.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Threading.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class ScriptExecutionContext;
class WebSocketChannelClient;
class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCounted<ThreadableWebSocketChannelClientWrapper> {
public:
static PassRefPtr<ThreadableWebSocketChannelClientWrapper> create(ScriptExecutionContext*, WebSocketChannelClient*);
void clearSyncMethodDone();
void setSyncMethodDone();
bool syncMethodDone() const;
WorkerThreadableWebSocketChannel::Peer* peer() const;
void didCreateWebSocketChannel(WorkerThreadableWebSocketChannel::Peer*);
void clearPeer();
bool failedWebSocketChannelCreation() const;
void setFailedWebSocketChannelCreation();
String subprotocol() const;
void setSubprotocol(const String&);
String extensions() const;
void setExtensions(const String&);
ThreadableWebSocketChannel::SendResult sendRequestResult() const;
void setSendRequestResult(ThreadableWebSocketChannel::SendResult);
unsigned long bufferedAmount() const;
void setBufferedAmount(unsigned long);
void clearClient();
void didConnect();
void didReceiveMessage(const String& message);
void didReceiveBinaryData(PassOwnPtr<Vector<char>>);
void didUpdateBufferedAmount(unsigned long bufferedAmount);
void didStartClosingHandshake();
void didClose(unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
void didReceiveMessageError();
void suspend();
void resume();
private:
ThreadableWebSocketChannelClientWrapper(ScriptExecutionContext*, WebSocketChannelClient*);
static void processPendingTasksCallback(ScriptExecutionContext&, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
void processPendingTasks();
static void didConnectCallback(ScriptExecutionContext&, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
static void didReceiveMessageCallback(ScriptExecutionContext&, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, const String& message);
static void didReceiveBinaryDataCallback(ScriptExecutionContext&, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, PassOwnPtr<Vector<char>>);
static void didUpdateBufferedAmountCallback(ScriptExecutionContext&, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long bufferedAmount);
static void didStartClosingHandshakeCallback(ScriptExecutionContext&, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
static void didCloseCallback(ScriptExecutionContext&, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
static void didReceiveMessageErrorCallback(ScriptExecutionContext&, PassRefPtr<ThreadableWebSocketChannelClientWrapper>);
ScriptExecutionContext* m_context;
WebSocketChannelClient* m_client;
WorkerThreadableWebSocketChannel::Peer* m_peer;
bool m_failedWebSocketChannelCreation;
bool m_syncMethodDone;
Vector<UChar> m_subprotocol;
Vector<UChar> m_extensions;
ThreadableWebSocketChannel::SendResult m_sendRequestResult;
unsigned long m_bufferedAmount;
bool m_suspended;
Vector<std::unique_ptr<ScriptExecutionContext::Task>> m_pendingTasks;
};
}
#endif // ENABLE(WEB_SOCKETS)
#endif // ThreadableWebSocketChannelClientWrapper_h