|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set sw=2 ts=8 et tw=80 : */ |
|
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 |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_net_WebSocketChannelChild_h |
|
8 #define mozilla_net_WebSocketChannelChild_h |
|
9 |
|
10 #include "mozilla/net/PWebSocketChild.h" |
|
11 #include "mozilla/net/BaseWebSocketChannel.h" |
|
12 #include "nsString.h" |
|
13 |
|
14 namespace mozilla { |
|
15 namespace net { |
|
16 |
|
17 class ChannelEvent; |
|
18 class ChannelEventQueue; |
|
19 |
|
20 class WebSocketChannelChild : public BaseWebSocketChannel, |
|
21 public PWebSocketChild |
|
22 { |
|
23 public: |
|
24 WebSocketChannelChild(bool aSecure); |
|
25 ~WebSocketChannelChild(); |
|
26 |
|
27 NS_DECL_ISUPPORTS |
|
28 NS_DECL_NSITHREADRETARGETABLEREQUEST |
|
29 |
|
30 // nsIWebSocketChannel methods BaseWebSocketChannel didn't implement for us |
|
31 // |
|
32 NS_IMETHOD AsyncOpen(nsIURI *aURI, const nsACString &aOrigin, |
|
33 nsIWebSocketListener *aListener, nsISupports *aContext); |
|
34 NS_IMETHOD Close(uint16_t code, const nsACString & reason); |
|
35 NS_IMETHOD SendMsg(const nsACString &aMsg); |
|
36 NS_IMETHOD SendBinaryMsg(const nsACString &aMsg); |
|
37 NS_IMETHOD SendBinaryStream(nsIInputStream *aStream, uint32_t aLength); |
|
38 nsresult SendBinaryStream(OptionalInputStreamParams *aStream, uint32_t aLength); |
|
39 NS_IMETHOD GetSecurityInfo(nsISupports **aSecurityInfo); |
|
40 |
|
41 void AddIPDLReference(); |
|
42 void ReleaseIPDLReference(); |
|
43 |
|
44 private: |
|
45 bool RecvOnStart(const nsCString& aProtocol, const nsCString& aExtensions) MOZ_OVERRIDE; |
|
46 bool RecvOnStop(const nsresult& aStatusCode) MOZ_OVERRIDE; |
|
47 bool RecvOnMessageAvailable(const nsCString& aMsg) MOZ_OVERRIDE; |
|
48 bool RecvOnBinaryMessageAvailable(const nsCString& aMsg) MOZ_OVERRIDE; |
|
49 bool RecvOnAcknowledge(const uint32_t& aSize) MOZ_OVERRIDE; |
|
50 bool RecvOnServerClose(const uint16_t& aCode, const nsCString &aReason) MOZ_OVERRIDE; |
|
51 |
|
52 void OnStart(const nsCString& aProtocol, const nsCString& aExtensions); |
|
53 void OnStop(const nsresult& aStatusCode); |
|
54 void OnMessageAvailable(const nsCString& aMsg); |
|
55 void OnBinaryMessageAvailable(const nsCString& aMsg); |
|
56 void OnAcknowledge(const uint32_t& aSize); |
|
57 void OnServerClose(const uint16_t& aCode, const nsCString& aReason); |
|
58 void AsyncOpenFailed(); |
|
59 |
|
60 void DispatchToTargetThread(ChannelEvent *aChannelEvent); |
|
61 |
|
62 nsRefPtr<ChannelEventQueue> mEventQ; |
|
63 bool mIPCOpen; |
|
64 |
|
65 friend class StartEvent; |
|
66 friend class StopEvent; |
|
67 friend class MessageEvent; |
|
68 friend class AcknowledgeEvent; |
|
69 friend class ServerCloseEvent; |
|
70 friend class AsyncOpenFailedEvent; |
|
71 }; |
|
72 |
|
73 } // namespace net |
|
74 } // namespace mozilla |
|
75 |
|
76 #endif // mozilla_net_WebSocketChannelChild_h |