mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1540731 - Part 3: Stop releasing actors within ActorDestroy, r=mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D29606 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
95e8f0306b
commit
30555bd898
@ -21,23 +21,6 @@
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
class SimpleChannel : public nsBaseChannel {
|
||||
public:
|
||||
explicit SimpleChannel(UniquePtr<SimpleChannelCallbacks>&& aCallbacks);
|
||||
|
||||
protected:
|
||||
virtual ~SimpleChannel() = default;
|
||||
|
||||
virtual nsresult OpenContentStream(bool async, nsIInputStream** streamOut,
|
||||
nsIChannel** channel) override;
|
||||
|
||||
virtual nsresult BeginAsyncRead(nsIStreamListener* listener,
|
||||
nsIRequest** request) override;
|
||||
|
||||
private:
|
||||
UniquePtr<SimpleChannelCallbacks> mCallbacks;
|
||||
};
|
||||
|
||||
SimpleChannel::SimpleChannel(UniquePtr<SimpleChannelCallbacks>&& aCallbacks)
|
||||
: mCallbacks(std::move(aCallbacks)) {
|
||||
EnableSynthesizedProgressEvents(true);
|
||||
@ -72,31 +55,11 @@ nsresult SimpleChannel::BeginAsyncRead(nsIStreamListener* listener,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class SimpleChannelChild final : public SimpleChannel,
|
||||
public nsIChildChannel,
|
||||
public PSimpleChannelChild {
|
||||
public:
|
||||
explicit SimpleChannelChild(UniquePtr<SimpleChannelCallbacks>&& aCallbacks);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSICHILDCHANNEL
|
||||
|
||||
protected:
|
||||
virtual void ActorDestroy(ActorDestroyReason why) override;
|
||||
|
||||
private:
|
||||
virtual ~SimpleChannelChild() = default;
|
||||
|
||||
void AddIPDLReference();
|
||||
|
||||
RefPtr<SimpleChannelChild> mIPDLRef;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(SimpleChannelChild, SimpleChannel, nsIChildChannel)
|
||||
|
||||
SimpleChannelChild::SimpleChannelChild(
|
||||
UniquePtr<SimpleChannelCallbacks>&& aCallbacks)
|
||||
: SimpleChannel(std::move(aCallbacks)), mIPDLRef(nullptr) {}
|
||||
: SimpleChannel(std::move(aCallbacks)) {}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SimpleChannelChild::ConnectParent(uint32_t aId) {
|
||||
@ -107,19 +70,19 @@ SimpleChannelChild::ConnectParent(uint32_t aId) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!gNeckoChild->SendPSimpleChannelConstructor(this, aId)) {
|
||||
// Reference freed in DeallocPSimpleChannelChild.
|
||||
if (!gNeckoChild->SendPSimpleChannelConstructor(do_AddRef(this).take(),
|
||||
aId)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// IPC now has a ref to us.
|
||||
mIPDLRef = this;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SimpleChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener,
|
||||
nsISupports* aContext) {
|
||||
if (mIPDLRef) {
|
||||
if (CanSend()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
@ -130,17 +93,12 @@ SimpleChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener,
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (mIPDLRef) {
|
||||
if (CanSend()) {
|
||||
Unused << Send__delete__(this);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void SimpleChannelChild::ActorDestroy(ActorDestroyReason why) {
|
||||
MOZ_ASSERT(mIPDLRef);
|
||||
mIPDLRef = nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIChannel> NS_NewSimpleChannelInternal(
|
||||
nsIURI* aURI, nsILoadInfo* aLoadInfo,
|
||||
UniquePtr<SimpleChannelCallbacks>&& aCallbacks) {
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
#include "mozilla/ResultExtensions.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsBaseChannel.h"
|
||||
#include "nsIChildChannel.h"
|
||||
#include "mozilla/net/PSimpleChannelChild.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIChannel;
|
||||
@ -64,6 +67,36 @@ class SimpleChannelCallbacksImpl final : public SimpleChannelCallbacks {
|
||||
RefPtr<T> mContext;
|
||||
};
|
||||
|
||||
class SimpleChannel : public nsBaseChannel {
|
||||
public:
|
||||
explicit SimpleChannel(UniquePtr<SimpleChannelCallbacks>&& aCallbacks);
|
||||
|
||||
protected:
|
||||
virtual ~SimpleChannel() = default;
|
||||
|
||||
virtual nsresult OpenContentStream(bool async, nsIInputStream** streamOut,
|
||||
nsIChannel** channel) override;
|
||||
|
||||
virtual nsresult BeginAsyncRead(nsIStreamListener* listener,
|
||||
nsIRequest** request) override;
|
||||
|
||||
private:
|
||||
UniquePtr<SimpleChannelCallbacks> mCallbacks;
|
||||
};
|
||||
|
||||
class SimpleChannelChild final : public SimpleChannel,
|
||||
public nsIChildChannel,
|
||||
public PSimpleChannelChild {
|
||||
public:
|
||||
explicit SimpleChannelChild(UniquePtr<SimpleChannelCallbacks>&& aCallbacks);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSICHILDCHANNEL
|
||||
|
||||
private:
|
||||
virtual ~SimpleChannelChild() = default;
|
||||
};
|
||||
|
||||
already_AddRefed<nsIChannel> NS_NewSimpleChannelInternal(
|
||||
nsIURI* aURI, nsILoadInfo* aLoadInfo,
|
||||
UniquePtr<SimpleChannelCallbacks>&& aCallbacks);
|
||||
|
@ -135,6 +135,7 @@ EXPORTS += [
|
||||
'netCore.h',
|
||||
'nsASocketHandler.h',
|
||||
'nsAsyncRedirectVerifyHelper.h',
|
||||
'nsBaseChannel.h',
|
||||
'nsFileStreams.h',
|
||||
'nsInputStreamPump.h',
|
||||
'nsMIMEInputStream.h',
|
||||
@ -169,6 +170,7 @@ EXPORTS.mozilla.net += [
|
||||
'NetworkConnectivityService.h',
|
||||
'PartiallySeekableInputStream.h',
|
||||
'Predictor.h',
|
||||
'PrivateBrowsingChannel.h',
|
||||
'RedirectChannelRegistrar.h',
|
||||
'ReferrerPolicy.h',
|
||||
'RequestContextService.h',
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsIThreadRetargetableRequest.h"
|
||||
#include "nsIThreadRetargetableStreamListener.h"
|
||||
#include "PrivateBrowsingChannel.h"
|
||||
#include "mozilla/net/PrivateBrowsingChannel.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
class nsIInputStream;
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "mozilla/net/HttpChannelChild.h"
|
||||
#include "mozilla/net/CookieServiceChild.h"
|
||||
#include "mozilla/net/FTPChannelChild.h"
|
||||
#include "mozilla/net/DataChannelChild.h"
|
||||
#include "mozilla/net/FileChannelChild.h"
|
||||
#include "mozilla/net/WebSocketChannelChild.h"
|
||||
#include "mozilla/net/WebSocketEventListenerChild.h"
|
||||
#include "mozilla/net/DNSRequestChild.h"
|
||||
@ -38,6 +40,7 @@
|
||||
#include "nsQueryObject.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "SimpleChannel.h"
|
||||
|
||||
using mozilla::dom::TCPServerSocketChild;
|
||||
using mozilla::dom::TCPSocketChild;
|
||||
@ -220,7 +223,7 @@ PDataChannelChild* NeckoChild::AllocPDataChannelChild(
|
||||
}
|
||||
|
||||
bool NeckoChild::DeallocPDataChannelChild(PDataChannelChild* child) {
|
||||
// NB: See DataChannelChild::ActorDestroy.
|
||||
static_cast<DataChannelChild*>(child)->Release();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -231,7 +234,7 @@ PFileChannelChild* NeckoChild::AllocPFileChannelChild(
|
||||
}
|
||||
|
||||
bool NeckoChild::DeallocPFileChannelChild(PFileChannelChild* child) {
|
||||
// NB: See FileChannelChild::ActorDestroy.
|
||||
static_cast<FileChannelChild*>(child)->Release();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -242,7 +245,7 @@ PSimpleChannelChild* NeckoChild::AllocPSimpleChannelChild(
|
||||
}
|
||||
|
||||
bool NeckoChild::DeallocPSimpleChannelChild(PSimpleChannelChild* child) {
|
||||
// NB: See SimpleChannelChild::ActorDestroy.
|
||||
static_cast<SimpleChannelChild*>(child)->Release();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -52,14 +52,13 @@ DataChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener,
|
||||
}
|
||||
|
||||
void DataChannelChild::AddIPDLReference() {
|
||||
AddRef();
|
||||
AddRef(); // Released in NeckoChild::DeallocPDataChannelChild.
|
||||
mIPCOpen = true;
|
||||
}
|
||||
|
||||
void DataChannelChild::ActorDestroy(ActorDestroyReason why) {
|
||||
MOZ_ASSERT(mIPCOpen);
|
||||
mIPCOpen = false;
|
||||
Release();
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
@ -5,11 +5,13 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS.mozilla.net += [
|
||||
'DataChannelChild.h',
|
||||
'DataChannelParent.h',
|
||||
]
|
||||
|
||||
EXPORTS += [
|
||||
'nsDataHandler.h',
|
||||
'nsDataChannel.h',
|
||||
'nsDataHandler.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
|
@ -53,14 +53,13 @@ FileChannelChild::CompleteRedirectSetup(nsIStreamListener* listener,
|
||||
}
|
||||
|
||||
void FileChannelChild::AddIPDLReference() {
|
||||
AddRef();
|
||||
AddRef(); // Released in NeckoChild::DeallocPFileChannelChild.
|
||||
mIPCOpen = true;
|
||||
}
|
||||
|
||||
void FileChannelChild::ActorDestroy(ActorDestroyReason why) {
|
||||
MOZ_ASSERT(mIPCOpen);
|
||||
mIPCOpen = false;
|
||||
Release();
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
@ -8,10 +8,15 @@ with Files('**'):
|
||||
BUG_COMPONENT = ('Core', 'Networking: File')
|
||||
|
||||
EXPORTS.mozilla.net += [
|
||||
'FileChannelChild.h',
|
||||
'FileChannelParent.h',
|
||||
'nsFileProtocolHandler.h',
|
||||
]
|
||||
|
||||
EXPORTS += [
|
||||
'nsFileChannel.h',
|
||||
]
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIFileChannel.idl',
|
||||
'nsIFileProtocolHandler.idl',
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "nsIEventTarget.h"
|
||||
|
||||
#include "nsIStreamListener.h"
|
||||
#include "PrivateBrowsingChannel.h"
|
||||
#include "mozilla/net/PrivateBrowsingChannel.h"
|
||||
|
||||
class nsIEventTarget;
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "nsILoadInfo.h"
|
||||
#include "mozilla/net/NeckoCommon.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "PrivateBrowsingChannel.h"
|
||||
#include "mozilla/net/PrivateBrowsingChannel.h"
|
||||
#include "mozilla/net/DNS.h"
|
||||
#include "nsITimedChannel.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "nsIResumableChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsHashPropertyBag.h"
|
||||
#include "PrivateBrowsingChannel.h"
|
||||
#include "mozilla/net/PrivateBrowsingChannel.h"
|
||||
|
||||
namespace IPC {
|
||||
class URI;
|
||||
|
Loading…
Reference in New Issue
Block a user