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"
12 #include "nsIUDPSocket.h"
13 #include "nsIUDPSocketFilter.h"
14 #include "mozilla/net/OfflineObserver.h"
15 #include "mozilla/dom/PermissionMessageUtils.h"
20 class UDPSocketParent
: public mozilla::net::PUDPSocketParent
21 , public nsIUDPSocketListener
22 , public mozilla::net::DisconnectableParent
25 NS_DECL_THREADSAFE_ISUPPORTS
26 NS_DECL_NSIUDPSOCKETLISTENER
30 bool Init(const IPC::Principal
& aPrincipal
, const nsACString
& aFilter
);
32 virtual bool RecvBind(const UDPAddressInfo
& aAddressInfo
,
33 const bool& aAddressReuse
, const bool& aLoopback
) MOZ_OVERRIDE
;
35 virtual bool RecvOutgoingData(const UDPData
& aData
, const UDPSocketAddr
& aAddr
) MOZ_OVERRIDE
;
37 virtual bool RecvClose() MOZ_OVERRIDE
;
39 virtual bool RecvRequestDelete() MOZ_OVERRIDE
;
40 virtual bool RecvJoinMulticast(const nsCString
& aMulticastAddress
,
41 const nsCString
& aInterface
) MOZ_OVERRIDE
;
42 virtual bool RecvLeaveMulticast(const nsCString
& aMulticastAddress
,
43 const nsCString
& aInterface
) MOZ_OVERRIDE
;
44 virtual nsresult
OfflineNotification(nsISupports
*) MOZ_OVERRIDE
;
45 virtual uint32_t GetAppId() MOZ_OVERRIDE
;
48 virtual ~UDPSocketParent();
50 virtual void ActorDestroy(ActorDestroyReason why
) MOZ_OVERRIDE
;
51 void Send(const InfallibleTArray
<uint8_t>& aData
, const UDPSocketAddr
& aAddr
);
52 void Send(const InputStreamParams
& aStream
, const UDPSocketAddr
& aAddr
);
53 nsresult
BindInternal(const nsCString
& aHost
, const uint16_t& aPort
,
54 const bool& aAddressReuse
, const bool& aLoopback
);
56 void FireInternalError(uint32_t aLineNo
);
59 nsCOMPtr
<nsIUDPSocket
> mSocket
;
60 nsCOMPtr
<nsIUDPSocketFilter
> mFilter
;
61 nsRefPtr
<mozilla::net::OfflineObserver
> mObserver
;
62 nsCOMPtr
<nsIPrincipal
> mPrincipal
;
66 } // namespace mozilla
68 #endif // !defined(mozilla_dom_UDPSocketParent_h__)