michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set sw=2 ts=8 et tw=80 : */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_net_WebSocketChannelChild_h michael@0: #define mozilla_net_WebSocketChannelChild_h michael@0: michael@0: #include "mozilla/net/PWebSocketChild.h" michael@0: #include "mozilla/net/BaseWebSocketChannel.h" michael@0: #include "nsString.h" michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: class ChannelEvent; michael@0: class ChannelEventQueue; michael@0: michael@0: class WebSocketChannelChild : public BaseWebSocketChannel, michael@0: public PWebSocketChild michael@0: { michael@0: public: michael@0: WebSocketChannelChild(bool aSecure); michael@0: ~WebSocketChannelChild(); michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSITHREADRETARGETABLEREQUEST michael@0: michael@0: // nsIWebSocketChannel methods BaseWebSocketChannel didn't implement for us michael@0: // michael@0: NS_IMETHOD AsyncOpen(nsIURI *aURI, const nsACString &aOrigin, michael@0: nsIWebSocketListener *aListener, nsISupports *aContext); michael@0: NS_IMETHOD Close(uint16_t code, const nsACString & reason); michael@0: NS_IMETHOD SendMsg(const nsACString &aMsg); michael@0: NS_IMETHOD SendBinaryMsg(const nsACString &aMsg); michael@0: NS_IMETHOD SendBinaryStream(nsIInputStream *aStream, uint32_t aLength); michael@0: nsresult SendBinaryStream(OptionalInputStreamParams *aStream, uint32_t aLength); michael@0: NS_IMETHOD GetSecurityInfo(nsISupports **aSecurityInfo); michael@0: michael@0: void AddIPDLReference(); michael@0: void ReleaseIPDLReference(); michael@0: michael@0: private: michael@0: bool RecvOnStart(const nsCString& aProtocol, const nsCString& aExtensions) MOZ_OVERRIDE; michael@0: bool RecvOnStop(const nsresult& aStatusCode) MOZ_OVERRIDE; michael@0: bool RecvOnMessageAvailable(const nsCString& aMsg) MOZ_OVERRIDE; michael@0: bool RecvOnBinaryMessageAvailable(const nsCString& aMsg) MOZ_OVERRIDE; michael@0: bool RecvOnAcknowledge(const uint32_t& aSize) MOZ_OVERRIDE; michael@0: bool RecvOnServerClose(const uint16_t& aCode, const nsCString &aReason) MOZ_OVERRIDE; michael@0: michael@0: void OnStart(const nsCString& aProtocol, const nsCString& aExtensions); michael@0: void OnStop(const nsresult& aStatusCode); michael@0: void OnMessageAvailable(const nsCString& aMsg); michael@0: void OnBinaryMessageAvailable(const nsCString& aMsg); michael@0: void OnAcknowledge(const uint32_t& aSize); michael@0: void OnServerClose(const uint16_t& aCode, const nsCString& aReason); michael@0: void AsyncOpenFailed(); michael@0: michael@0: void DispatchToTargetThread(ChannelEvent *aChannelEvent); michael@0: michael@0: nsRefPtr mEventQ; michael@0: bool mIPCOpen; michael@0: michael@0: friend class StartEvent; michael@0: friend class StopEvent; michael@0: friend class MessageEvent; michael@0: friend class AcknowledgeEvent; michael@0: friend class ServerCloseEvent; michael@0: friend class AsyncOpenFailedEvent; michael@0: }; michael@0: michael@0: } // namespace net michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_net_WebSocketChannelChild_h