2013-11-29 20:13:44 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-05-10 16:00:28 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_UDPSocketParent_h__
|
|
|
|
#define mozilla_dom_UDPSocketParent_h__
|
|
|
|
|
|
|
|
#include "mozilla/net/PUDPSocketParent.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIUDPSocket.h"
|
2013-11-29 20:13:44 +04:00
|
|
|
#include "nsIUDPSocketFilter.h"
|
2014-08-23 03:16:31 +04:00
|
|
|
#include "mozilla/net/OfflineObserver.h"
|
2015-04-08 22:35:00 +03:00
|
|
|
#include "mozilla/dom/PermissionMessageUtils.h"
|
2013-05-10 16:00:28 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2015-05-29 17:14:14 +03:00
|
|
|
namespace net {
|
|
|
|
class PNeckoParent;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace net
|
2015-05-29 17:14:14 +03:00
|
|
|
|
2013-05-10 16:00:28 +04:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class UDPSocketParent : public mozilla::net::PUDPSocketParent
|
|
|
|
, public nsIUDPSocketListener
|
2014-08-23 03:16:31 +04:00
|
|
|
, public mozilla::net::DisconnectableParent
|
2013-05-10 16:00:28 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSIUDPSOCKETLISTENER
|
|
|
|
|
2015-05-29 17:14:14 +03:00
|
|
|
explicit UDPSocketParent(PBackgroundParent* aManager);
|
|
|
|
explicit UDPSocketParent(PNeckoParent* aManager);
|
2013-11-29 20:13:44 +04:00
|
|
|
|
2015-04-08 22:35:00 +03:00
|
|
|
bool Init(const IPC::Principal& aPrincipal, const nsACString& aFilter);
|
2014-05-06 14:32:25 +04:00
|
|
|
|
|
|
|
virtual bool RecvBind(const UDPAddressInfo& aAddressInfo,
|
2015-03-21 19:28:04 +03:00
|
|
|
const bool& aAddressReuse, const bool& aLoopback) override;
|
2014-05-06 14:32:25 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool RecvOutgoingData(const UDPData& aData, const UDPSocketAddr& aAddr) override;
|
2013-05-10 16:00:28 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool RecvClose() override;
|
|
|
|
virtual bool RecvRequestDelete() override;
|
2014-05-06 14:32:25 +04:00
|
|
|
virtual bool RecvJoinMulticast(const nsCString& aMulticastAddress,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsCString& aInterface) override;
|
2014-05-06 14:32:25 +04:00
|
|
|
virtual bool RecvLeaveMulticast(const nsCString& aMulticastAddress,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsCString& aInterface) override;
|
|
|
|
virtual nsresult OfflineNotification(nsISupports *) override;
|
|
|
|
virtual uint32_t GetAppId() override;
|
2013-05-10 16:00:28 +04:00
|
|
|
|
|
|
|
private:
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~UDPSocketParent();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason why) override;
|
2014-05-06 14:32:25 +04:00
|
|
|
void Send(const InfallibleTArray<uint8_t>& aData, const UDPSocketAddr& aAddr);
|
|
|
|
void Send(const InputStreamParams& aStream, const UDPSocketAddr& aAddr);
|
|
|
|
nsresult BindInternal(const nsCString& aHost, const uint16_t& aPort,
|
|
|
|
const bool& aAddressReuse, const bool& aLoopback);
|
|
|
|
|
|
|
|
void FireInternalError(uint32_t aLineNo);
|
2013-05-10 16:00:28 +04:00
|
|
|
|
2015-05-29 17:14:14 +03:00
|
|
|
// One of these will be null and the other non-null.
|
|
|
|
PBackgroundParent* mBackgroundManager;
|
|
|
|
PNeckoParent* mNeckoManager;
|
|
|
|
|
2013-05-10 16:00:28 +04:00
|
|
|
bool mIPCOpen;
|
|
|
|
nsCOMPtr<nsIUDPSocket> mSocket;
|
2013-11-29 20:13:44 +04:00
|
|
|
nsCOMPtr<nsIUDPSocketFilter> mFilter;
|
2014-08-23 03:16:31 +04:00
|
|
|
nsRefPtr<mozilla::net::OfflineObserver> mObserver;
|
2015-04-08 22:35:00 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
2013-05-10 16:00:28 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // !defined(mozilla_dom_UDPSocketParent_h__)
|