|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef mozilla_dom_TCPSocketParent_h |
|
6 #define mozilla_dom_TCPSocketParent_h |
|
7 |
|
8 #include "mozilla/net/PTCPSocketParent.h" |
|
9 #include "nsITCPSocketParent.h" |
|
10 #include "nsCycleCollectionParticipant.h" |
|
11 #include "nsCOMPtr.h" |
|
12 #include "nsIDOMTCPSocket.h" |
|
13 #include "js/TypeDecls.h" |
|
14 |
|
15 #define TCPSOCKETPARENT_CID \ |
|
16 { 0x4e7246c6, 0xa8b3, 0x426d, { 0x9c, 0x17, 0x76, 0xda, 0xb1, 0xe1, 0xe1, 0x4a } } |
|
17 |
|
18 namespace mozilla { |
|
19 namespace dom { |
|
20 |
|
21 class PBrowserParent; |
|
22 |
|
23 class TCPSocketParentBase : public nsITCPSocketParent |
|
24 { |
|
25 public: |
|
26 NS_DECL_CYCLE_COLLECTION_CLASS(TCPSocketParentBase) |
|
27 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
28 |
|
29 void AddIPDLReference(); |
|
30 void ReleaseIPDLReference(); |
|
31 |
|
32 protected: |
|
33 TCPSocketParentBase(); |
|
34 virtual ~TCPSocketParentBase(); |
|
35 |
|
36 nsCOMPtr<nsITCPSocketIntermediary> mIntermediary; |
|
37 nsCOMPtr<nsIDOMTCPSocket> mSocket; |
|
38 bool mIPCOpen; |
|
39 }; |
|
40 |
|
41 class TCPSocketParent : public mozilla::net::PTCPSocketParent |
|
42 , public TCPSocketParentBase |
|
43 { |
|
44 public: |
|
45 NS_DECL_NSITCPSOCKETPARENT |
|
46 NS_IMETHOD_(MozExternalRefCountType) Release() MOZ_OVERRIDE; |
|
47 |
|
48 TCPSocketParent() : mIntermediaryObj(nullptr) {} |
|
49 |
|
50 virtual bool RecvOpen(const nsString& aHost, const uint16_t& aPort, |
|
51 const bool& useSSL, const nsString& aBinaryType); |
|
52 |
|
53 virtual bool RecvStartTLS() MOZ_OVERRIDE; |
|
54 virtual bool RecvSuspend() MOZ_OVERRIDE; |
|
55 virtual bool RecvResume() MOZ_OVERRIDE; |
|
56 virtual bool RecvClose() MOZ_OVERRIDE; |
|
57 virtual bool RecvData(const SendableData& aData, |
|
58 const uint32_t& aTrackingNumber) MOZ_OVERRIDE; |
|
59 virtual bool RecvRequestDelete() MOZ_OVERRIDE; |
|
60 |
|
61 private: |
|
62 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
|
63 |
|
64 JSObject* mIntermediaryObj; |
|
65 }; |
|
66 |
|
67 } // namespace dom |
|
68 } // namespace mozilla |
|
69 |
|
70 #endif |