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 {
25 public:
26   NS_DECL_CYCLE_COLLECTION_CLASS(TCPServerSocketParent)
27   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
28 
29   TCPServerSocketParent(PNeckoParent* neckoParent, uint16_t aLocalPort,
30                         uint16_t aBacklog, bool aUseArrayBuffers);
31 
32   void Init();
33 
34   virtual bool RecvClose() override;
35   virtual bool RecvRequestDelete() override;
36 
37   uint32_t GetAppId();
38   bool GetInIsolatedMozBrowser();
39 
40   void AddIPDLReference();
41   void ReleaseIPDLReference();
42 
43   void OnConnect(TCPServerSocketEvent* event);
44 
45 private:
46   ~TCPServerSocketParent();
47 
48   nsresult SendCallbackAccept(TCPSocketParent *socket);
49 
50   virtual void ActorDestroy(ActorDestroyReason why) override;
51 
52   PNeckoParent* mNeckoParent;
53   RefPtr<TCPServerSocket> mServerSocket;
54   bool mIPCOpen;
55 };
56 
57 } // namespace dom
58 } // namespace mozilla
59 
60 #endif // mozilla_dom_TCPServerSocketParent_h
61