ThreadableWebSocketChannelClientWrapper.h [plain text]
#pragma once
#include "ScriptExecutionContext.h"
#include "ThreadableWebSocketChannel.h"
#include "WebSocketChannelClient.h"
#include "WorkerThreadableWebSocketChannel.h"
#include <memory>
#include <wtf/Forward.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class ScriptExecutionContext;
class WebSocketChannelClient;
class ThreadableWebSocketChannelClientWrapper : public ThreadSafeRefCounted<ThreadableWebSocketChannelClientWrapper> {
public:
static Ref<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 bufferedAmount() const;
void setBufferedAmount(unsigned);
void clearClient();
void didConnect();
void didReceiveMessage(const String& message);
void didReceiveBinaryData(Vector<uint8_t>&&);
void didUpdateBufferedAmount(unsigned bufferedAmount);
void didStartClosingHandshake();
void didClose(unsigned unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
void didReceiveMessageError();
void didUpgradeURL();
void suspend();
void resume();
private:
ThreadableWebSocketChannelClientWrapper(ScriptExecutionContext&, WebSocketChannelClient&);
void processPendingTasks();
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 m_bufferedAmount;
bool m_suspended;
Vector<std::unique_ptr<ScriptExecutionContext::Task>> m_pendingTasks;
};
}