WebSocketConnectionChild.h (1902B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set sw=2 ts=8 et ft=cpp : */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_net_WebSocketConnectionChild_h 8 #define mozilla_net_WebSocketConnectionChild_h 9 10 #include "mozilla/net/PWebSocketConnectionChild.h" 11 #include "mozilla/net/WebSocketConnectionListener.h" 12 #include "nsIHttpChannelInternal.h" 13 14 namespace mozilla { 15 namespace net { 16 17 class WebSocketConnection; 18 19 // WebSocketConnectionChild only lives in socket process and uses 20 // WebSocketConnection to send/read data from socket. Only IPDL holds a strong 21 // reference to WebSocketConnectionChild, so the life time of 22 // WebSocketConnectionChild is bound to the IPC actor. 23 24 class WebSocketConnectionChild final : public PWebSocketConnectionChild, 25 public nsIHttpUpgradeListener, 26 public WebSocketConnectionListener { 27 public: 28 NS_DECL_THREADSAFE_ISUPPORTS 29 NS_DECL_NSIHTTPUPGRADELISTENER 30 31 WebSocketConnectionChild(); 32 void Init(uint32_t aListenerId); 33 mozilla::ipc::IPCResult RecvWriteOutputData(nsTArray<uint8_t>&& aData); 34 mozilla::ipc::IPCResult RecvStartReading(); 35 mozilla::ipc::IPCResult RecvDrainSocketData(); 36 mozilla::ipc::IPCResult Recv__delete__() override; 37 38 void ActorDestroy(ActorDestroyReason aWhy) override; 39 40 void OnError(nsresult aStatus) override; 41 void OnTCPClosed() override; 42 nsresult OnDataReceived(uint8_t* aData, uint32_t aCount) override; 43 44 private: 45 virtual ~WebSocketConnectionChild(); 46 47 RefPtr<WebSocketConnection> mConnection; 48 nsCOMPtr<nsIEventTarget> mSocketThread; 49 }; 50 51 } // namespace net 52 } // namespace mozilla 53 54 #endif // mozilla_net_WebSocketConnectionChild_h