Bug 1307491 - (Part 3) Remove support for per-app-offline in don/network [nukeb2g] r=baku

MozReview-Commit-ID: KCg4R3LD8AE

--HG--
extra : rebase_source : 91060bc89aa8e76e2e06d848a9e7297c171dd85b
This commit is contained in:
Valentin Gosu 2016-10-17 03:58:59 +02:00
Родитель 08a83ff913
Коммит 02543ae9c1
4 изменённых файлов: 1 добавлений и 87 удалений

Просмотреть файл

@ -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<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()
{
@ -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);

Просмотреть файл

@ -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<TCPSocket> mSocket;
RefPtr<mozilla::net::OfflineObserver> 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);

Просмотреть файл

@ -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<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

Просмотреть файл

@ -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<nsIUDPSocket> mSocket;
nsCOMPtr<nsISocketFilter> mFilter;
RefPtr<mozilla::net::OfflineObserver> mObserver;
nsCOMPtr<nsIPrincipal> mPrincipal;
};