1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/protocol/websocket/WebSocketChannelChild.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set sw=2 ts=8 et tw=80 : */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_net_WebSocketChannelChild_h 1.11 +#define mozilla_net_WebSocketChannelChild_h 1.12 + 1.13 +#include "mozilla/net/PWebSocketChild.h" 1.14 +#include "mozilla/net/BaseWebSocketChannel.h" 1.15 +#include "nsString.h" 1.16 + 1.17 +namespace mozilla { 1.18 +namespace net { 1.19 + 1.20 +class ChannelEvent; 1.21 +class ChannelEventQueue; 1.22 + 1.23 +class WebSocketChannelChild : public BaseWebSocketChannel, 1.24 + public PWebSocketChild 1.25 +{ 1.26 + public: 1.27 + WebSocketChannelChild(bool aSecure); 1.28 + ~WebSocketChannelChild(); 1.29 + 1.30 + NS_DECL_ISUPPORTS 1.31 + NS_DECL_NSITHREADRETARGETABLEREQUEST 1.32 + 1.33 + // nsIWebSocketChannel methods BaseWebSocketChannel didn't implement for us 1.34 + // 1.35 + NS_IMETHOD AsyncOpen(nsIURI *aURI, const nsACString &aOrigin, 1.36 + nsIWebSocketListener *aListener, nsISupports *aContext); 1.37 + NS_IMETHOD Close(uint16_t code, const nsACString & reason); 1.38 + NS_IMETHOD SendMsg(const nsACString &aMsg); 1.39 + NS_IMETHOD SendBinaryMsg(const nsACString &aMsg); 1.40 + NS_IMETHOD SendBinaryStream(nsIInputStream *aStream, uint32_t aLength); 1.41 + nsresult SendBinaryStream(OptionalInputStreamParams *aStream, uint32_t aLength); 1.42 + NS_IMETHOD GetSecurityInfo(nsISupports **aSecurityInfo); 1.43 + 1.44 + void AddIPDLReference(); 1.45 + void ReleaseIPDLReference(); 1.46 + 1.47 + private: 1.48 + bool RecvOnStart(const nsCString& aProtocol, const nsCString& aExtensions) MOZ_OVERRIDE; 1.49 + bool RecvOnStop(const nsresult& aStatusCode) MOZ_OVERRIDE; 1.50 + bool RecvOnMessageAvailable(const nsCString& aMsg) MOZ_OVERRIDE; 1.51 + bool RecvOnBinaryMessageAvailable(const nsCString& aMsg) MOZ_OVERRIDE; 1.52 + bool RecvOnAcknowledge(const uint32_t& aSize) MOZ_OVERRIDE; 1.53 + bool RecvOnServerClose(const uint16_t& aCode, const nsCString &aReason) MOZ_OVERRIDE; 1.54 + 1.55 + void OnStart(const nsCString& aProtocol, const nsCString& aExtensions); 1.56 + void OnStop(const nsresult& aStatusCode); 1.57 + void OnMessageAvailable(const nsCString& aMsg); 1.58 + void OnBinaryMessageAvailable(const nsCString& aMsg); 1.59 + void OnAcknowledge(const uint32_t& aSize); 1.60 + void OnServerClose(const uint16_t& aCode, const nsCString& aReason); 1.61 + void AsyncOpenFailed(); 1.62 + 1.63 + void DispatchToTargetThread(ChannelEvent *aChannelEvent); 1.64 + 1.65 + nsRefPtr<ChannelEventQueue> mEventQ; 1.66 + bool mIPCOpen; 1.67 + 1.68 + friend class StartEvent; 1.69 + friend class StopEvent; 1.70 + friend class MessageEvent; 1.71 + friend class AcknowledgeEvent; 1.72 + friend class ServerCloseEvent; 1.73 + friend class AsyncOpenFailedEvent; 1.74 +}; 1.75 + 1.76 +} // namespace net 1.77 +} // namespace mozilla 1.78 + 1.79 +#endif // mozilla_net_WebSocketChannelChild_h