Bug 1832033: change `CheckPopoverValidity` to match spec more closely. r=emilio
[gecko.git] / dom / network / UDPSocketParent.h
blob6d4a982bae1946d811bedb24791e4b34cdcb4c8a
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/. */
7 #ifndef mozilla_dom_UDPSocketParent_h__
8 #define mozilla_dom_UDPSocketParent_h__
10 #include "mozilla/net/PUDPSocketParent.h"
11 #include "nsCOMPtr.h"
12 #include "nsIUDPSocket.h"
13 #include "nsISocketFilter.h"
14 #include "mozilla/dom/PermissionMessageUtils.h"
16 namespace mozilla {
17 namespace net {
18 class PNeckoParent;
19 } // namespace net
21 namespace dom {
23 class UDPSocketParent : public mozilla::net::PUDPSocketParent,
24 public nsIUDPSocketListener {
25 public:
26 NS_DECL_THREADSAFE_ISUPPORTS
27 NS_DECL_NSIUDPSOCKETLISTENER
29 explicit UDPSocketParent(PBackgroundParent* aManager);
30 explicit UDPSocketParent(PNeckoParent* aManager);
32 bool Init(nsIPrincipal* aPrincipal, const nsACString& aFilter);
34 mozilla::ipc::IPCResult RecvBind(const UDPAddressInfo& aAddressInfo,
35 const bool& aAddressReuse,
36 const bool& aLoopback,
37 const uint32_t& recvBufferSize,
38 const uint32_t& sendBufferSize);
39 mozilla::ipc::IPCResult RecvConnect(const UDPAddressInfo& aAddressInfo);
40 void DoSendConnectResponse(const UDPAddressInfo& aAddressInfo);
41 void SendConnectResponse(const nsCOMPtr<nsIEventTarget>& aThread,
42 const UDPAddressInfo& aAddressInfo);
43 void DoConnect(const nsCOMPtr<nsIUDPSocket>& aSocket,
44 const nsCOMPtr<nsIEventTarget>& aReturnThread,
45 const UDPAddressInfo& aAddressInfo);
47 mozilla::ipc::IPCResult RecvOutgoingData(const UDPData& aData,
48 const UDPSocketAddr& aAddr);
50 mozilla::ipc::IPCResult RecvClose();
51 mozilla::ipc::IPCResult RecvRequestDelete();
52 mozilla::ipc::IPCResult RecvJoinMulticast(const nsCString& aMulticastAddress,
53 const nsCString& aInterface);
54 mozilla::ipc::IPCResult RecvLeaveMulticast(const nsCString& aMulticastAddress,
55 const nsCString& aInterface);
57 private:
58 virtual ~UDPSocketParent();
60 virtual void ActorDestroy(ActorDestroyReason why) override;
61 void Send(const nsTArray<uint8_t>& aData, const UDPSocketAddr& aAddr);
62 void Send(const IPCStream& aStream, const UDPSocketAddr& aAddr);
63 nsresult BindInternal(const nsCString& aHost, const uint16_t& aPort,
64 const bool& aAddressReuse, const bool& aLoopback,
65 const uint32_t& recvBufferSize,
66 const uint32_t& sendBufferSize);
67 nsresult ConnectInternal(const nsCString& aHost, const uint16_t& aPort);
68 void FireInternalError(uint32_t aLineNo);
69 void SendInternalError(const nsCOMPtr<nsIEventTarget>& aThread,
70 uint32_t aLineNo);
72 PBackgroundParent* mBackgroundManager;
74 bool mIPCOpen;
75 nsCOMPtr<nsIUDPSocket> mSocket;
76 nsCOMPtr<nsISocketFilter> mFilter;
77 nsCOMPtr<nsIPrincipal> mPrincipal;
78 UDPAddressInfo mAddress;
81 } // namespace dom
82 } // namespace mozilla
84 #endif // !defined(mozilla_dom_UDPSocketParent_h__)