1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 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 file,
5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_dom_TCPServerSocketParent_h
8 #define mozilla_dom_TCPServerSocketParent_h
9 
10 #include "mozilla/net/PNeckoParent.h"
11 #include "mozilla/net/PTCPServerSocketParent.h"
12 #include "nsCycleCollectionParticipant.h"
13 #include "nsCOMPtr.h"
14 
15 namespace mozilla {
16 namespace dom {
17 
18 class TCPServerSocket;
19 class TCPServerSocketEvent;
20 class TCPSocketParent;
21 
22 class TCPServerSocketParent : public mozilla::net::PTCPServerSocketParent,
23                               public nsISupports {
24  public:
25   NS_DECL_CYCLE_COLLECTION_CLASS(TCPServerSocketParent)
26   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
27 
28   TCPServerSocketParent(PNeckoParent* neckoParent, uint16_t aLocalPort,
29                         uint16_t aBacklog, bool aUseArrayBuffers);
30 
31   void Init();
32 
33   mozilla::ipc::IPCResult RecvClose();
34   mozilla::ipc::IPCResult RecvRequestDelete();
35 
36   void AddIPDLReference();
37   void ReleaseIPDLReference();
38 
39   void OnConnect(TCPServerSocketEvent* event);
40 
41  private:
42   ~TCPServerSocketParent();
43 
44   nsresult SendCallbackAccept(TCPSocketParent* socket);
45 
46   virtual void ActorDestroy(ActorDestroyReason why) override;
47 
48   PNeckoParent* mNeckoParent;
49   RefPtr<TCPServerSocket> mServerSocket;
50   bool mIPCOpen;
51 };
52 
53 }  // namespace dom
54 }  // namespace mozilla
55 
56 #endif  // mozilla_dom_TCPServerSocketParent_h
57