diff --git a/dom/network/TCPSocketParent.cpp b/dom/network/TCPSocketParent.cpp index 662022ce505c..768fcdb55f40 100644 --- a/dom/network/TCPSocketParent.cpp +++ b/dom/network/TCPSocketParent.cpp @@ -64,14 +64,10 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPSocketParentBase) TCPSocketParentBase::TCPSocketParentBase() : mIPCOpen(false) { - mObserver = new mozilla::net::OfflineObserver(this); } TCPSocketParentBase::~TCPSocketParentBase() { - if (mObserver) { - mObserver->RemoveObserver(); - } } uint32_t @@ -98,33 +94,6 @@ TCPSocketParent::GetInIsolatedMozBrowser() } } -nsresult -TCPSocketParent::OfflineNotification(nsISupports *aSubject) -{ - nsCOMPtr 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() { @@ -167,12 +136,6 @@ TCPSocketParent::RecvOpen(const nsString& aHost, const uint16_t& aPort, const bo 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); diff --git a/dom/network/TCPSocketParent.h b/dom/network/TCPSocketParent.h index 27f44968ac0e..e44e340bbf2b 100644 --- a/dom/network/TCPSocketParent.h +++ b/dom/network/TCPSocketParent.h @@ -13,7 +13,6 @@ #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 } } @@ -24,7 +23,6 @@ namespace dom { class TCPSocket; class TCPSocketParentBase : public nsISupports - , public mozilla::net::DisconnectableParent { public: NS_DECL_CYCLE_COLLECTION_CLASS(TCPSocketParentBase) @@ -38,7 +36,6 @@ protected: virtual ~TCPSocketParentBase(); RefPtr mSocket; - RefPtr mObserver; bool mIPCOpen; }; @@ -68,8 +65,6 @@ public: 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); @@ -82,6 +77,7 @@ public: 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); diff --git a/dom/network/UDPSocketParent.cpp b/dom/network/UDPSocketParent.cpp index d917dd08a13d..886af32c1993 100644 --- a/dom/network/UDPSocketParent.cpp +++ b/dom/network/UDPSocketParent.cpp @@ -15,9 +15,6 @@ #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" @@ -33,7 +30,6 @@ UDPSocketParent::UDPSocketParent(PBackgroundParent* aManager) , mNeckoManager(nullptr) , mIPCOpen(true) { - mObserver = new mozilla::net::OfflineObserver(this); } UDPSocketParent::UDPSocketParent(PNeckoParent* aManager) @@ -41,46 +37,10 @@ UDPSocketParent::UDPSocketParent(PNeckoParent* aManager) , mNeckoManager(aManager) , mIPCOpen(true) { - mObserver = new mozilla::net::OfflineObserver(this); } UDPSocketParent::~UDPSocketParent() { - if (mObserver) { - mObserver->RemoveObserver(); - } -} - -nsresult -UDPSocketParent::OfflineNotification(nsISupports *aSubject) -{ - nsCOMPtr 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 diff --git a/dom/network/UDPSocketParent.h b/dom/network/UDPSocketParent.h index 5795d8c8fe38..4b828e0133be 100644 --- a/dom/network/UDPSocketParent.h +++ b/dom/network/UDPSocketParent.h @@ -11,7 +11,6 @@ #include "nsCOMPtr.h" #include "nsIUDPSocket.h" #include "nsISocketFilter.h" -#include "mozilla/net/OfflineObserver.h" #include "mozilla/dom/PermissionMessageUtils.h" namespace mozilla { @@ -23,7 +22,6 @@ namespace dom { class UDPSocketParent : public mozilla::net::PUDPSocketParent , public nsIUDPSocketListener - , public mozilla::net::DisconnectableParent { public: NS_DECL_THREADSAFE_ISUPPORTS @@ -54,8 +52,6 @@ public: 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(); @@ -79,7 +75,6 @@ private: bool mIPCOpen; nsCOMPtr mSocket; nsCOMPtr mFilter; - RefPtr mObserver; nsCOMPtr mPrincipal; };