WebSocket: Pass the value of useHixie76Protocol flag to WebSocket object
[WebKit-https.git] / Source / WebCore / websockets / WorkerThreadableWebSocketChannel.h
index 366e4fa7c0d5f2ae4b38fa0183a77e68626a32e7..f230fd7afaf92dbfb19ae0815bd2f5514ce2a9e2 100644 (file)
@@ -52,6 +52,7 @@ class WorkerLoaderProxy;
 class WorkerRunLoop;
 
 class WorkerThreadableWebSocketChannel : public RefCounted<WorkerThreadableWebSocketChannel>, public ThreadableWebSocketChannel {
+    WTF_MAKE_FAST_ALLOCATED;
 public:
     static PassRefPtr<ThreadableWebSocketChannel> create(WorkerContext* workerContext, WebSocketChannelClient* client, const String& taskMode, const KURL& url, const String& protocol)
     {
@@ -59,10 +60,12 @@ public:
     }
     virtual ~WorkerThreadableWebSocketChannel();
 
+    virtual bool useHixie76Protocol();
     virtual void connect();
     virtual bool send(const String& message);
     virtual unsigned long bufferedAmount() const;
     virtual void close();
+    virtual void fail(const String& reason);
     virtual void disconnect(); // Will suppress didClose().
     virtual void suspend();
     virtual void resume();
@@ -77,28 +80,32 @@ protected:
 private:
     // Generated by the bridge.  The Peer and its bridge should have identical
     // lifetimes.
-    class Peer : public WebSocketChannelClient, public Noncopyable {
+    class Peer : public WebSocketChannelClient {
+        WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED;
     public:
-        static Peer* create(RefPtr<ThreadableWebSocketChannelClientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context, const String& taskMode, const KURL& url, const String& protocol)
+        static Peer* create(PassRefPtr<ThreadableWebSocketChannelClientWrapper> clientWrapper, WorkerLoaderProxy& loaderProxy, ScriptExecutionContext* context, const String& taskMode, const KURL& url, const String& protocol)
         {
             return new Peer(clientWrapper, loaderProxy, context, taskMode, url, protocol);
         }
         ~Peer();
 
+        bool useHixie76Protocol();
         void connect();
         void send(const String& message);
         void bufferedAmount();
         void close();
+        void fail(const String& reason);
         void disconnect();
         void suspend();
         void resume();
 
         virtual void didConnect();
         virtual void didReceiveMessage(const String& message);
-        virtual void didClose(unsigned long unhandledBufferedAmount);
+        virtual void didStartClosingHandshake();
+        virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshakeCompletionStatus);
 
     private:
-        Peer(RefPtr<ThreadableWebSocketChannelClientWrapper>, WorkerLoaderProxy&, ScriptExecutionContext*, const String& taskMode, const KURL&, const String& protocol);
+        Peer(PassRefPtr<ThreadableWebSocketChannelClientWrapper>, WorkerLoaderProxy&, ScriptExecutionContext*, const String& taskMode, const KURL&, const String& protocol);
 
         RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper;
         WorkerLoaderProxy& m_loaderProxy;
@@ -118,6 +125,7 @@ private:
         bool send(const String& message);
         unsigned long bufferedAmount();
         void close();
+        void fail(const String& reason);
         void disconnect();
         void suspend();
         void resume();
@@ -128,10 +136,10 @@ private:
     private:
         Bridge(PassRefPtr<ThreadableWebSocketChannelClientWrapper>, PassRefPtr<WorkerContext>, const String& taskMode, const KURL&, const String& protocol);
 
-        static void setWebSocketChannel(ScriptExecutionContext*, Bridge* thisPtr, Peer*, RefPtr<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, RefPtr<ThreadableWebSocketChannelClientWrapper>, const String& taskMode, const KURL&, const String& protocol);
+        static void mainThreadCreateWebSocketChannel(ScriptExecutionContext*, Bridge* thisPtr, PassRefPtr<ThreadableWebSocketChannelClientWrapper>, const String& taskMode, const KURL&, const String& protocol);
 
         // Executed on the worker context's thread.
         void clearClientWrapper();
@@ -152,6 +160,7 @@ private:
     static void mainThreadSend(ScriptExecutionContext*, Peer*, const String& message);
     static void mainThreadBufferedAmount(ScriptExecutionContext*, Peer*);
     static void mainThreadClose(ScriptExecutionContext*, Peer*);
+    static void mainThreadFail(ScriptExecutionContext*, Peer*, const String& reason);
     static void mainThreadDestroy(ScriptExecutionContext*, Peer*);
     static void mainThreadSuspend(ScriptExecutionContext*, Peer*);
     static void mainThreadResume(ScriptExecutionContext*, Peer*);