Bug 1307491 - (Part 3) Remove support for per-app-offline in don/network [nukeb2g] r=baku
MozReview-Commit-ID: KCg4R3LD8AE
--- a/dom/network/TCPSocketParent.cpp
+++ b/dom/network/TCPSocketParent.cpp
@@ -59,24 +59,20 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION(TCPSocketParentBase, mSocket)
NS_IMPL_CYCLE_COLLECTING_ADDREF(TCPSocketParentBase)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPSocketParentBase)
TCPSocketParentBase::TCPSocketParentBase()
: mIPCOpen(false)
{
- mObserver = new mozilla::net::OfflineObserver(this);
}
TCPSocketParentBase::~TCPSocketParentBase()
{
- if (mObserver) {
- mObserver->RemoveObserver();
- }
}
uint32_t
TCPSocketParent::GetAppId()
{
const PContentParent *content = Manager()->Manager();
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
TabParent *tab = TabParent::GetFrom(browser);
@@ -93,43 +89,16 @@ TCPSocketParent::GetInIsolatedMozBrowser
if (PBrowserParent* browser = SingleManagedOrNull(content->ManagedPBrowserParent())) {
TabParent *tab = TabParent::GetFrom(browser);
return tab->IsIsolatedMozBrowserElement();
} else {
return false;
}
}
-nsresult
-TCPSocketParent::OfflineNotification(nsISupports *aSubject)
-{
- nsCOMPtr<nsIAppOfflineInfo> info(do_QueryInterface(aSubject));
- if (!info) {
- return NS_OK;
- }
-
- uint32_t targetAppId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
- info->GetAppId(&targetAppId);
-
- // Obtain App ID
- uint32_t appId = GetAppId();
- if (appId != targetAppId) {
- return NS_OK;
- }
-
- // If the app is offline, close the socket
- if (mSocket && NS_IsAppOffline(appId)) {
- mSocket->Close();
- mSocket = nullptr;
- }
-
- return NS_OK;
-}
-
-
void
TCPSocketParentBase::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
this->Release();
}
@@ -162,22 +131,16 @@ TCPSocketParent::RecvOpen(const nsString
FireInteralError(this, __LINE__);
return true;
}
// Obtain App ID
uint32_t appId = GetAppId();
bool inIsolatedMozBrowser = GetInIsolatedMozBrowser();
- if (NS_IsAppOffline(appId)) {
- NS_ERROR("Can't open socket because app is offline");
- FireInteralError(this, __LINE__);
- return true;
- }
-
mSocket = new TCPSocket(nullptr, aHost, aPort, aUseSSL, aUseArrayBuffers);
mSocket->SetAppIdAndBrowser(appId, inIsolatedMozBrowser);
mSocket->SetSocketBridgeParent(this);
NS_ENSURE_SUCCESS(mSocket->Init(), true);
return true;
}
bool
--- a/dom/network/TCPSocketParent.h
+++ b/dom/network/TCPSocketParent.h
@@ -8,42 +8,39 @@
#define mozilla_dom_TCPSocketParent_h
#include "mozilla/dom/TCPSocketBinding.h"
#include "mozilla/net/PTCPSocketParent.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCOMPtr.h"
#include "nsISocketFilter.h"
#include "js/TypeDecls.h"
-#include "mozilla/net/OfflineObserver.h"
#define TCPSOCKETPARENT_CID \
{ 0x4e7246c6, 0xa8b3, 0x426d, { 0x9c, 0x17, 0x76, 0xda, 0xb1, 0xe1, 0xe1, 0x4a } }
namespace mozilla {
namespace dom {
class TCPSocket;
class TCPSocketParentBase : public nsISupports
- , public mozilla::net::DisconnectableParent
{
public:
NS_DECL_CYCLE_COLLECTION_CLASS(TCPSocketParentBase)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
void AddIPDLReference();
void ReleaseIPDLReference();
protected:
TCPSocketParentBase();
virtual ~TCPSocketParentBase();
RefPtr<TCPSocket> mSocket;
- RefPtr<mozilla::net::OfflineObserver> mObserver;
bool mIPCOpen;
};
class TCPSocketParent : public mozilla::net::PTCPSocketParent
, public TCPSocketParentBase
{
public:
NS_IMETHOD_(MozExternalRefCountType) Release() override;
@@ -63,30 +60,29 @@ public:
virtual bool RecvStartTLS() override;
virtual bool RecvSuspend() override;
virtual bool RecvResume() override;
virtual bool RecvClose() override;
virtual bool RecvData(const SendableData& aData,
const uint32_t& aTrackingNumber) override;
virtual bool RecvRequestDelete() override;
- virtual nsresult OfflineNotification(nsISupports *) override;
- virtual uint32_t GetAppId() override;
bool GetInIsolatedMozBrowser();
void FireErrorEvent(const nsAString& aName, const nsAString& aType, TCPReadyState aReadyState);
void FireEvent(const nsAString& aType, TCPReadyState aReadyState);
void FireArrayBufferDataEvent(nsTArray<uint8_t>& aBuffer, TCPReadyState aReadyState);
void FireStringDataEvent(const nsACString& aData, TCPReadyState aReadyState);
void SetSocket(TCPSocket *socket);
nsresult GetHost(nsAString& aHost);
nsresult GetPort(uint16_t* aPort);
private:
+ virtual uint32_t GetAppId();
virtual void ActorDestroy(ActorDestroyReason why) override;
void SendEvent(const nsAString& aType, CallbackData aData, TCPReadyState aReadyState);
nsresult SetFilter(const nsCString& aFilter);
nsCOMPtr<nsISocketFilter> mFilter;
};
} // namespace dom
--- a/dom/network/UDPSocketParent.cpp
+++ b/dom/network/UDPSocketParent.cpp
@@ -10,82 +10,42 @@
#include "nsIUDPSocket.h"
#include "nsINetAddr.h"
#include "mozilla/AppProcessChecker.h"
#include "mozilla/Unused.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/net/DNS.h"
#include "mozilla/net/NeckoCommon.h"
#include "mozilla/net/PNeckoParent.h"
-#include "nsNetUtil.h"
-#include "mozilla/dom/ContentParent.h"
-#include "mozilla/dom/TabParent.h"
#include "nsIPermissionManager.h"
#include "nsIScriptSecurityManager.h"
#include "mozilla/ipc/PBackgroundParent.h"
#include "mtransport/runnable_utils.h"
namespace mozilla {
namespace dom {
NS_IMPL_ISUPPORTS(UDPSocketParent, nsIUDPSocketListener)
UDPSocketParent::UDPSocketParent(PBackgroundParent* aManager)
: mBackgroundManager(aManager)
, mNeckoManager(nullptr)
, mIPCOpen(true)
{
- mObserver = new mozilla::net::OfflineObserver(this);
}
UDPSocketParent::UDPSocketParent(PNeckoParent* aManager)
: mBackgroundManager(nullptr)
, mNeckoManager(aManager)
, mIPCOpen(true)
{
- mObserver = new mozilla::net::OfflineObserver(this);
}
UDPSocketParent::~UDPSocketParent()
{
- if (mObserver) {
- mObserver->RemoveObserver();
- }
-}
-
-nsresult
-UDPSocketParent::OfflineNotification(nsISupports *aSubject)
-{
- nsCOMPtr<nsIAppOfflineInfo> info(do_QueryInterface(aSubject));
- if (!info) {
- return NS_OK;
- }
-
- uint32_t targetAppId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
- info->GetAppId(&targetAppId);
-
- // Obtain App ID
- uint32_t appId = GetAppId();
- if (appId != targetAppId) {
- return NS_OK;
- }
-
- // If the app is offline, close the socket
- if (mSocket && NS_IsAppOffline(appId)) {
- mSocket->Close();
- }
-
- return NS_OK;
-}
-
-uint32_t
-UDPSocketParent::GetAppId()
-{
- return mPrincipal ? mPrincipal->GetAppId()
- : nsIScriptSecurityManager::UNKNOWN_APP_ID;
}
bool
UDPSocketParent::Init(const IPC::Principal& aPrincipal,
const nsACString& aFilter)
{
MOZ_ASSERT_IF(mBackgroundManager, !aPrincipal);
// will be used once we move all UDPSocket to PBackground, or
--- a/dom/network/UDPSocketParent.h
+++ b/dom/network/UDPSocketParent.h
@@ -6,29 +6,27 @@
#ifndef mozilla_dom_UDPSocketParent_h__
#define mozilla_dom_UDPSocketParent_h__
#include "mozilla/net/PUDPSocketParent.h"
#include "nsCOMPtr.h"
#include "nsIUDPSocket.h"
#include "nsISocketFilter.h"
-#include "mozilla/net/OfflineObserver.h"
#include "mozilla/dom/PermissionMessageUtils.h"
namespace mozilla {
namespace net {
class PNeckoParent;
} // namespace net
namespace dom {
class UDPSocketParent : public mozilla::net::PUDPSocketParent
, public nsIUDPSocketListener
- , public mozilla::net::DisconnectableParent
{
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIUDPSOCKETLISTENER
explicit UDPSocketParent(PBackgroundParent* aManager);
explicit UDPSocketParent(PNeckoParent* aManager);
@@ -49,18 +47,16 @@ public:
virtual bool RecvOutgoingData(const UDPData& aData, const UDPSocketAddr& aAddr) override;
virtual bool RecvClose() override;
virtual bool RecvRequestDelete() override;
virtual bool RecvJoinMulticast(const nsCString& aMulticastAddress,
const nsCString& aInterface) override;
virtual bool RecvLeaveMulticast(const nsCString& aMulticastAddress,
const nsCString& aInterface) override;
- virtual nsresult OfflineNotification(nsISupports *) override;
- virtual uint32_t GetAppId() override;
private:
virtual ~UDPSocketParent();
virtual void ActorDestroy(ActorDestroyReason why) override;
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,
@@ -74,16 +70,15 @@ private:
// One of these will be null and the other non-null.
PBackgroundParent* mBackgroundManager;
PNeckoParent* mNeckoManager;
bool mIPCOpen;
nsCOMPtr<nsIUDPSocket> mSocket;
nsCOMPtr<nsISocketFilter> mFilter;
- RefPtr<mozilla::net::OfflineObserver> mObserver;
nsCOMPtr<nsIPrincipal> mPrincipal;
};
} // namespace dom
} // namespace mozilla
#endif // !defined(mozilla_dom_UDPSocketParent_h__)