Bug 1509591 - Part 2: Remove now-unnecessary mIPCOpen variable, r=mccr8

This should eliminate most variables which can be replaced with IPCOpen().

Differential Revision: https://phabricator.services.mozilla.com/D12957
This commit is contained in:
Nika Layzell 2018-11-23 18:01:03 -05:00
Родитель 0f1b2fff2a
Коммит 6bda5576a0
56 изменённых файлов: 105 добавлений и 339 удалений

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

@ -992,7 +992,6 @@ RemotePermissionRequest::RemotePermissionRequest(
nsPIDOMWindowInner* aWindow)
: mRequest(aRequest)
, mWindow(aWindow)
, mIPCOpen(false)
, mDestroyed(false)
{
mListener = new VisibilityChangeListener(mWindow);
@ -1001,7 +1000,8 @@ RemotePermissionRequest::RemotePermissionRequest(
RemotePermissionRequest::~RemotePermissionRequest()
{
MOZ_ASSERT(!mIPCOpen, "Protocol must not be open when RemotePermissionRequest is destroyed.");
MOZ_ASSERT(!mozilla::ipc::IProtocol::IPCOpen(),
"Protocol must not be open when RemotePermissionRequest is destroyed.");
}
void

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

@ -234,19 +234,19 @@ public:
void IPDLAddRef()
{
mIPCOpen = true;
AddRef();
}
void IPDLRelease()
{
mIPCOpen = false;
Release();
}
void Destroy();
bool IPCOpen() const { return mIPCOpen && !mDestroyed; }
bool IPCOpen() const {
return mozilla::ipc::IProtocol::IPCOpen() && !mDestroyed;
}
private:
virtual ~RemotePermissionRequest();
@ -256,7 +256,6 @@ private:
nsCOMPtr<nsIContentPermissionRequest> mRequest;
nsCOMPtr<nsPIDOMWindowInner> mWindow;
bool mIPCOpen;
bool mDestroyed;
RefPtr<VisibilityChangeListener> mListener;
};

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

@ -1484,7 +1484,7 @@ ContentParent::ShutDownProcess(ShutDownMethod aMethod)
}
}
if (mIPCOpen && !mShutdownPending) {
if (IPCOpen() && !mShutdownPending) {
// Stop sending input events with input priority when shutting down.
SetInputPriorityEventEnabled(false);
if (SendShutdown()) {
@ -1687,10 +1687,6 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
mForceKillTimer = nullptr;
}
// Signal shutdown completion regardless of error state, so we can
// finish waiting in the xpcom-shutdown/profile-before-change observer.
mIPCOpen = false;
if (mHangMonitorActor) {
ProcessHangMonitor::RemoveProcess(mHangMonitorActor);
mHangMonitorActor = nullptr;
@ -1944,7 +1940,7 @@ ContentParent::NotifyTabDestroying(const TabId& aTabId,
void
ContentParent::StartForceKillTimer()
{
if (mForceKillTimer || !mIPCOpen) {
if (mForceKillTimer || !IPCOpen()) {
return;
}
@ -2401,7 +2397,6 @@ ContentParent::ContentParent(ContentParent* aOpener,
, mCalledKillHard(false)
, mCreatedPairedMinidumps(false)
, mShutdownPending(false)
, mIPCOpen(true)
, mIsRemoteInputEventQueueEnabled(false)
, mIsInputPriorityEventEnabled(false)
, mHangMonitorActor(nullptr)
@ -2906,7 +2901,7 @@ ContentParent::IsInputEventQueueSupported()
void
ContentParent::OnVarChanged(const GfxVarUpdate& aVar)
{
if (!mIPCOpen) {
if (!IPCOpen()) {
return;
}
Unused << SendVarUpdate(aVar);
@ -3140,7 +3135,7 @@ ContentParent::Observe(nsISupports* aSubject,
// Wait for shutdown to complete, so that we receive any shutdown
// data (e.g. telemetry) from the child before we quit.
// This loop terminate prematurely based on mForceKillTimer.
SpinEventLoopUntil([&]() { return !mIPCOpen || mCalledKillHard; });
SpinEventLoopUntil([&]() { return !IPCOpen() || mCalledKillHard; });
NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
}

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

@ -288,7 +288,7 @@ public:
#endif
// Let managees query if it is safe to send messages.
bool IsDestroyed() const { return !mIPCOpen; }
bool IsDestroyed() const { return !IPCOpen(); }
virtual mozilla::ipc::IPCResult RecvCreateChildProcess(const IPCTabContext& aContext,
const hal::ProcessPriority& aPriority,
@ -1351,7 +1351,6 @@ private:
bool mCalledKillHard;
bool mCreatedPairedMinidumps;
bool mShutdownPending;
bool mIPCOpen;
// True if the input event queue on the main thread of the content process is
// enabled.

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

@ -154,9 +154,6 @@ class HangMonitorChild
JSContext* mContext;
bool mShutdownDone;
// This field is only accessed on the hang thread.
bool mIPCOpen;
// Allows us to ensure we NotifyActivity only once, allowing
// either thread to do so.
Atomic<bool> mPaintWhileInterruptingJSActive;
@ -276,9 +273,6 @@ private:
// This field is read-only after construction.
bool mReportHangs;
// This field is only accessed on the hang thread.
bool mIPCOpen;
Monitor mMonitor;
// Must be accessed with mMonitor held.
@ -311,7 +305,6 @@ HangMonitorChild::HangMonitorChild(ProcessHangMonitor* aMonitor)
mPaintWhileInterruptingJS(false),
mPaintWhileInterruptingJSForce(false),
mShutdownDone(false),
mIPCOpen(true),
mPaintWhileInterruptingJSActive(false)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
@ -393,8 +386,6 @@ HangMonitorChild::ActorDestroy(ActorDestroyReason aWhy)
{
MOZ_RELEASE_ASSERT(IsOnThread());
mIPCOpen = false;
// We use a task here to ensure that IPDL is finished with this
// HangMonitorChild before it gets deleted on the main thread.
Dispatch(NewNonOwningRunnableMethod("HangMonitorChild::ShutdownOnThread",
@ -488,7 +479,7 @@ HangMonitorChild::NotifySlowScriptAsync(TabId aTabId,
const nsCString& aFileName,
const nsString& aAddonId)
{
if (mIPCOpen) {
if (IPCOpen()) {
Unused << SendHangEvidence(SlowScriptData(aTabId, aFileName, aAddonId));
}
}
@ -574,7 +565,7 @@ HangMonitorChild::NotifyPluginHangAsync(uint32_t aPluginId)
MOZ_RELEASE_ASSERT(IsOnThread());
// bounce back to parent on background thread
if (mIPCOpen) {
if (IPCOpen()) {
Unused << SendHangEvidence(PluginHangData(aPluginId,
base::GetCurrentProcId()));
}
@ -606,7 +597,7 @@ HangMonitorChild::ClearHangAsync()
MOZ_RELEASE_ASSERT(IsOnThread());
// bounce back to parent on background thread
if (mIPCOpen) {
if (IPCOpen()) {
Unused << SendClearHang();
}
}
@ -615,7 +606,6 @@ HangMonitorChild::ClearHangAsync()
HangMonitorParent::HangMonitorParent(ProcessHangMonitor* aMonitor)
: mHangMonitor(aMonitor),
mIPCOpen(true),
mMonitor("HangMonitorParent lock"),
mShutdownDone(false),
mBrowserCrashDumpHashLock("mBrowserCrashDumpIds lock"),
@ -670,10 +660,9 @@ HangMonitorParent::ShutdownOnThread()
{
MOZ_RELEASE_ASSERT(IsOnThread());
// mIPCOpen is only written from this thread, so need need to take the lock
// here. We'd be shooting ourselves in the foot, because ActorDestroy takes
// it.
if (mIPCOpen) {
// Don't take the lock until after IPCOpen() is checked, as the actor lives on
// this thread and ActorDestroy will also take a lock.
if (IPCOpen()) {
Close();
}
@ -707,7 +696,7 @@ HangMonitorParent::PaintWhileInterruptingJSOnThread(TabId aTabId,
{
MOZ_RELEASE_ASSERT(IsOnThread());
if (mIPCOpen) {
if (IPCOpen()) {
Unused << SendPaintWhileInterruptingJS(aTabId, aForceRepaint, aEpoch);
}
}
@ -716,7 +705,6 @@ void
HangMonitorParent::ActorDestroy(ActorDestroyReason aWhy)
{
MOZ_RELEASE_ASSERT(IsOnThread());
mIPCOpen = false;
}
void
@ -859,7 +847,7 @@ HangMonitorParent::TerminateScript(bool aTerminateGlobal)
{
MOZ_RELEASE_ASSERT(IsOnThread());
if (mIPCOpen) {
if (IPCOpen()) {
Unused << SendTerminateScript(aTerminateGlobal);
}
}
@ -869,7 +857,7 @@ HangMonitorParent::BeginStartingDebugger()
{
MOZ_RELEASE_ASSERT(IsOnThread());
if (mIPCOpen) {
if (IPCOpen()) {
Unused << SendBeginStartingDebugger();
}
}
@ -879,7 +867,7 @@ HangMonitorParent::EndStartingDebugger()
{
MOZ_RELEASE_ASSERT(IsOnThread());
if (mIPCOpen) {
if (IPCOpen()) {
Unused << SendEndStartingDebugger();
}
}

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

@ -411,7 +411,6 @@ TabChild::TabChild(nsIContentChild* aManager,
, mUniqueId(aTabId)
, mHasSiblings(false)
, mIsTransparent(false)
, mIPCOpen(false)
, mParentIsActive(false)
, mDidSetRealShowInfo(false)
, mDidLoadURLInit(false)
@ -627,8 +626,6 @@ TabChild::Init(mozIDOMWindowProxy* aParent)
});
mAPZEventState = new APZEventState(mPuppetWidget, std::move(callback));
mIPCOpen = true;
// Recording/replaying processes use their own compositor.
if (recordreplay::IsRecordingOrReplaying()) {
mPuppetWidget->CreateCompositor();
@ -1039,8 +1036,6 @@ TabChild::DestroyWindow()
void
TabChild::ActorDestroy(ActorDestroyReason why)
{
mIPCOpen = false;
DestroyWindow();
if (mTabChildMessageManager) {

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

@ -588,8 +588,6 @@ public:
LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; }
LayoutDeviceIntPoint GetChromeOffset() const { return mChromeOffset; };
bool IPCOpen() const { return mIPCOpen; }
bool ParentIsActive() const
{
return mParentIsActive;
@ -852,7 +850,6 @@ private:
bool mIsTransparent;
bool mIPCOpen;
bool mParentIsActive;
CSSSize mUnscaledInnerSize;
bool mDidSetRealShowInfo;

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

@ -44,12 +44,6 @@ URLClassifierParent::StartClassify(nsIPrincipal* aPrincipal,
return IPC_OK();
}
void
URLClassifierParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}
/////////////////////////////////////////////////////////////////////
//URLClassifierLocalParent.
@ -79,9 +73,3 @@ URLClassifierLocalParent::StartClassify(nsIURI* aURI, const nsACString& aTables)
}
return IPC_OK();
}
void
URLClassifierLocalParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}

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

@ -25,7 +25,7 @@ public:
const nsACString& aProvider,
const nsACString& aFullHash) override
{
if (mIPCOpen) {
if (BaseProtocol::IPCOpen()) {
ClassifierInfo info = ClassifierInfo(nsCString(aList),
nsCString(aProvider),
nsCString(aFullHash));
@ -37,14 +37,13 @@ public:
// Custom.
void ClassificationFailed()
{
if (mIPCOpen) {
if (BaseProtocol::IPCOpen()) {
Unused << BaseProtocol::Send__delete__(this, void_t(), NS_ERROR_FAILURE);
}
}
protected:
~URLClassifierParentBase() = default;
bool mIPCOpen = true;
};
//////////////////////////////////////////////////////////////
@ -60,10 +59,6 @@ public:
bool* aSuccess);
private:
~URLClassifierParent() = default;
// Override PURLClassifierParent::ActorDestroy. We seem to unable to
// override from the base template class.
void ActorDestroy(ActorDestroyReason aWhy) override;
};
//////////////////////////////////////////////////////////////
@ -78,9 +73,6 @@ public:
private:
~URLClassifierLocalParent() = default;
// Override PURLClassifierParent::ActorDestroy.
void ActorDestroy(ActorDestroyReason aWhy) override;
};
} // namespace dom

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

@ -27,7 +27,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TCPServerSocketChildBase)
NS_INTERFACE_MAP_END
TCPServerSocketChildBase::TCPServerSocketChildBase()
: mIPCOpen(false)
{
}
@ -38,7 +37,7 @@ TCPServerSocketChildBase::~TCPServerSocketChildBase()
NS_IMETHODIMP_(MozExternalRefCountType) TCPServerSocketChild::Release(void)
{
nsrefcnt refcnt = TCPServerSocketChildBase::Release();
if (refcnt == 1 && mIPCOpen) {
if (refcnt == 1 && IPCOpen()) {
PTCPServerSocketChild::SendRequestDelete();
return 1;
}
@ -60,16 +59,12 @@ TCPServerSocketChild::TCPServerSocketChild(TCPServerSocket* aServerSocket, uint1
void
TCPServerSocketChildBase::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
this->Release();
}
void
TCPServerSocketChildBase::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}

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

@ -34,7 +34,6 @@ protected:
virtual ~TCPServerSocketChildBase();
RefPtr<TCPServerSocket> mServerSocket;
bool mIPCOpen;
};
class TCPServerSocketChild : public mozilla::net::PTCPServerSocketChild

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

@ -26,16 +26,12 @@ NS_INTERFACE_MAP_END
void
TCPServerSocketParent::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
this->Release();
}
void
TCPServerSocketParent::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}
@ -44,7 +40,6 @@ TCPServerSocketParent::TCPServerSocketParent(PNeckoParent* neckoParent,
uint16_t aBacklog,
bool aUseArrayBuffers)
: mNeckoParent(neckoParent)
, mIPCOpen(false)
{
mServerSocket = new TCPServerSocket(nullptr, aLocalPort, aUseArrayBuffers, aBacklog);
mServerSocket->SetServerBridgeParent(this);

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

@ -48,7 +48,6 @@ private:
PNeckoParent* mNeckoParent;
RefPtr<TCPServerSocket> mServerSocket;
bool mIPCOpen;
};
} // namespace dom

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

@ -69,7 +69,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TCPSocketChildBase)
NS_INTERFACE_MAP_END
TCPSocketChildBase::TCPSocketChildBase()
: mIPCOpen(false)
{
mozilla::HoldJSObjects(this);
}
@ -82,7 +81,7 @@ TCPSocketChildBase::~TCPSocketChildBase()
NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void)
{
nsrefcnt refcnt = TCPSocketChildBase::Release();
if (refcnt == 1 && mIPCOpen) {
if (refcnt == 1 && IPCOpen()) {
PTCPSocketChild::SendRequestDelete();
return 1;
}
@ -138,8 +137,6 @@ TCPSocketChild::SendWindowlessOpenBind(nsITCPSocketCallback* aSocket,
void
TCPSocketChildBase::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
mSocket = nullptr;
this->Release();
}
@ -147,8 +144,6 @@ TCPSocketChildBase::ReleaseIPDLReference()
void
TCPSocketChildBase::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}

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

@ -40,7 +40,6 @@ protected:
virtual ~TCPSocketChildBase();
nsCOMPtr<nsITCPSocketCallback> mSocket;
bool mIPCOpen;
};
class TCPSocketChild : public mozilla::net::PTCPSocketChild

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

@ -62,7 +62,6 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(TCPSocketParentBase)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TCPSocketParentBase)
TCPSocketParentBase::TCPSocketParentBase()
: mIPCOpen(false)
{
}
@ -73,23 +72,19 @@ TCPSocketParentBase::~TCPSocketParentBase()
void
TCPSocketParentBase::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
this->Release();
}
void
TCPSocketParentBase::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}
NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketParent::Release(void)
{
nsrefcnt refcnt = TCPSocketParentBase::Release();
if (refcnt == 1 && mIPCOpen) {
if (refcnt == 1 && IPCOpen()) {
mozilla::Unused << PTCPSocketParent::SendRequestDelete();
return 1;
}
@ -330,7 +325,7 @@ TCPSocketParent::FireStringDataEvent(const nsACString& aData, TCPReadyState aRea
void
TCPSocketParent::SendEvent(const nsAString& aType, CallbackData aData, TCPReadyState aReadyState)
{
if (mIPCOpen) {
if (IPCOpen()) {
mozilla::Unused << PTCPSocketParent::SendCallback(nsString(aType),
aData,
static_cast<uint32_t>(aReadyState));

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

@ -36,7 +36,6 @@ protected:
virtual ~TCPSocketParentBase();
RefPtr<TCPSocket> mSocket;
bool mIPCOpen;
};
class TCPSocketParent : public mozilla::net::PTCPSocketParent

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

@ -23,7 +23,6 @@ namespace dom {
NS_IMPL_ISUPPORTS(UDPSocketChildBase, nsIUDPSocketChild)
UDPSocketChildBase::UDPSocketChildBase()
: mIPCOpen(false)
{
}
@ -34,8 +33,6 @@ UDPSocketChildBase::~UDPSocketChildBase()
void
UDPSocketChildBase::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
mSocket = nullptr;
this->Release();
}
@ -43,15 +40,13 @@ UDPSocketChildBase::ReleaseIPDLReference()
void
UDPSocketChildBase::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen);
mIPCOpen = true;
this->AddRef();
}
NS_IMETHODIMP_(MozExternalRefCountType) UDPSocketChild::Release(void)
{
nsrefcnt refcnt = UDPSocketChildBase::Release();
if (refcnt == 1 && mIPCOpen) {
if (refcnt == 1 && IPCOpen()) {
PUDPSocketChild::SendRequestDelete();
return 1;
}

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

@ -29,7 +29,6 @@ protected:
UDPSocketChildBase();
virtual ~UDPSocketChildBase();
nsCOMPtr<nsIUDPSocketInternal> mSocket;
bool mIPCOpen;
};
class UDPSocketChild : public mozilla::net::PUDPSocketChild

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

@ -30,13 +30,11 @@ NS_IMPL_ISUPPORTS(UDPSocketParent, nsIUDPSocketListener)
UDPSocketParent::UDPSocketParent(PBackgroundParent* aManager)
: mBackgroundManager(aManager)
, mIPCOpen(true)
{
}
UDPSocketParent::UDPSocketParent(PNeckoParent* aManager)
: mBackgroundManager(nullptr)
, mIPCOpen(true)
{
}
@ -510,8 +508,6 @@ UDPSocketParent::RecvRequestDelete()
void
UDPSocketParent::ActorDestroy(ActorDestroyReason why)
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
if (mSocket) {
mSocket->Close();
}
@ -524,7 +520,7 @@ NS_IMETHODIMP
UDPSocketParent::OnPacketReceived(nsIUDPSocket* aSocket, nsIUDPMessage* aMessage)
{
// receiving packet from remote host, forward the message content to child process
if (!mIPCOpen) {
if (!IPCOpen()) {
return NS_OK;
}
@ -577,7 +573,7 @@ NS_IMETHODIMP
UDPSocketParent::OnStopListening(nsIUDPSocket* aSocket, nsresult aStatus)
{
// underlying socket is dead, send state update to child process
if (mIPCOpen) {
if (IPCOpen()) {
mozilla::Unused << SendCallbackClosed();
}
return NS_OK;
@ -586,7 +582,7 @@ UDPSocketParent::OnStopListening(nsIUDPSocket* aSocket, nsresult aStatus)
void
UDPSocketParent::FireInternalError(uint32_t aLineNo)
{
if (!mIPCOpen) {
if (!IPCOpen()) {
return;
}

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

@ -70,7 +70,6 @@ private:
PBackgroundParent* mBackgroundManager;
bool mIPCOpen;
nsCOMPtr<nsIUDPSocket> mSocket;
nsCOMPtr<nsISocketFilter> mFilter;
nsCOMPtr<nsIPrincipal> mPrincipal;

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

@ -129,23 +129,18 @@ private:
void
StorageDBChild::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempting to retain multiple IPDL references");
mIPCOpen = true;
AddRef();
}
void
StorageDBChild::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempting to release non-existent IPDL reference");
mIPCOpen = false;
Release();
}
StorageDBChild::StorageDBChild(LocalStorageManager* aManager)
: mManager(aManager)
, mStatus(NS_OK)
, mIPCOpen(false)
{
}
@ -248,7 +243,7 @@ StorageDBChild::Shutdown()
void
StorageDBChild::AsyncPreload(LocalStorageCacheBridge* aCache, bool aPriority)
{
if (mIPCOpen) {
if (IPCOpen()) {
// Adding ref to cache for the time of preload. This ensures a reference to
// to the cache and that all keys will load into this cache object.
mLoadingCaches.PutEntry(aCache);
@ -263,7 +258,7 @@ StorageDBChild::AsyncPreload(LocalStorageCacheBridge* aCache, bool aPriority)
void
StorageDBChild::AsyncGetUsage(StorageUsageBridge* aUsage)
{
if (mIPCOpen) {
if (IPCOpen()) {
SendAsyncGetUsage(aUsage->OriginScope());
}
}
@ -276,7 +271,7 @@ StorageDBChild::SyncPreload(LocalStorageCacheBridge* aCache, bool aForceSync)
return;
}
if (!mIPCOpen) {
if (!IPCOpen()) {
aCache->LoadDone(NS_ERROR_UNEXPECTED);
return;
}
@ -302,7 +297,7 @@ StorageDBChild::AsyncAddItem(LocalStorageCacheBridge* aCache,
const nsAString& aKey,
const nsAString& aValue)
{
if (NS_FAILED(mStatus) || !mIPCOpen) {
if (NS_FAILED(mStatus) || !IPCOpen()) {
return mStatus;
}
@ -317,7 +312,7 @@ StorageDBChild::AsyncUpdateItem(LocalStorageCacheBridge* aCache,
const nsAString& aKey,
const nsAString& aValue)
{
if (NS_FAILED(mStatus) || !mIPCOpen) {
if (NS_FAILED(mStatus) || !IPCOpen()) {
return mStatus;
}
@ -331,7 +326,7 @@ nsresult
StorageDBChild::AsyncRemoveItem(LocalStorageCacheBridge* aCache,
const nsAString& aKey)
{
if (NS_FAILED(mStatus) || !mIPCOpen) {
if (NS_FAILED(mStatus) || !IPCOpen()) {
return mStatus;
}
@ -343,7 +338,7 @@ StorageDBChild::AsyncRemoveItem(LocalStorageCacheBridge* aCache,
nsresult
StorageDBChild::AsyncClear(LocalStorageCacheBridge* aCache)
{
if (NS_FAILED(mStatus) || !mIPCOpen) {
if (NS_FAILED(mStatus) || !IPCOpen()) {
return mStatus;
}
@ -607,16 +602,12 @@ NS_IMPL_RELEASE(StorageDBParent)
void
StorageDBParent::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempting to retain multiple IPDL references");
mIPCOpen = true;
AddRef();
}
void
StorageDBParent::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempting to release non-existent IPDL reference");
mIPCOpen = false;
Release();
}
@ -626,7 +617,6 @@ namespace {
StorageDBParent::StorageDBParent(const nsString& aProfilePath)
: mProfilePath(aProfilePath)
, mIPCOpen(false)
{
AssertIsOnBackgroundThread();
@ -844,7 +834,7 @@ StorageDBParent::RecvAsyncAddItem(const nsCString& aOriginSuffix,
storageThread->AsyncAddItem(NewCache(aOriginSuffix, aOriginNoSuffix),
aKey,
aValue);
if (NS_FAILED(rv) && mIPCOpen) {
if (NS_FAILED(rv) && IPCOpen()) {
mozilla::Unused << SendError(rv);
}
@ -866,7 +856,7 @@ StorageDBParent::RecvAsyncUpdateItem(const nsCString& aOriginSuffix,
storageThread->AsyncUpdateItem(NewCache(aOriginSuffix, aOriginNoSuffix),
aKey,
aValue);
if (NS_FAILED(rv) && mIPCOpen) {
if (NS_FAILED(rv) && IPCOpen()) {
mozilla::Unused << SendError(rv);
}
@ -886,7 +876,7 @@ StorageDBParent::RecvAsyncRemoveItem(const nsCString& aOriginSuffix,
nsresult rv =
storageThread->AsyncRemoveItem(NewCache(aOriginSuffix, aOriginNoSuffix),
aKey);
if (NS_FAILED(rv) && mIPCOpen) {
if (NS_FAILED(rv) && IPCOpen()) {
mozilla::Unused << SendError(rv);
}
@ -904,7 +894,7 @@ StorageDBParent::RecvAsyncClear(const nsCString& aOriginSuffix,
nsresult rv =
storageThread->AsyncClear(NewCache(aOriginSuffix, aOriginNoSuffix));
if (NS_FAILED(rv) && mIPCOpen) {
if (NS_FAILED(rv) && IPCOpen()) {
mozilla::Unused << SendError(rv);
}
@ -980,7 +970,7 @@ StorageDBParent::Observe(const nsCString& aTopic,
const nsString& aOriginAttributesPattern,
const nsCString& aOriginScope)
{
if (mIPCOpen) {
if (IPCOpen()) {
mozilla::Unused <<
SendObserve(aTopic, aOriginAttributesPattern, aOriginScope);
}

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

@ -178,8 +178,6 @@ private:
// Status of the remote database
nsresult mStatus;
bool mIPCOpen;
};
class LocalStorageCacheParent final
@ -239,8 +237,6 @@ public:
void AddIPDLReference();
void ReleaseIPDLReference();
bool IPCOpen() { return mIPCOpen; }
public:
// Fake cache class receiving async callbacks from DB thread, sending
// them back to appropriate cache object on the child process.
@ -367,9 +363,6 @@ private:
ThreadSafeAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
// True when IPC channel is open and Send*() methods are OK to use.
bool mIPCOpen;
};
PBackgroundLocalStorageCacheParent*

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

@ -106,7 +106,6 @@ public:
, mTextureData(nullptr)
, mDestroyed(false)
, mMainThreadOnly(false)
, mIPCOpen(false)
, mOwnsTextureData(false)
, mOwnerCalledDestroy(false)
{}
@ -117,28 +116,12 @@ public:
void ActorDestroy(ActorDestroyReason why) override;
bool IPCOpen() const { return mIPCOpen; }
void Lock() const { if (mCompositableForwarder && mCompositableForwarder->GetTextureForwarder()->UsesImageBridge()) { mLock.Enter(); } }
void Unlock() const { if (mCompositableForwarder && mCompositableForwarder->GetTextureForwarder()->UsesImageBridge()) { mLock.Leave(); } }
private:
// AddIPDLReference and ReleaseIPDLReference are only to be called by CreateIPDLActor
// and DestroyIPDLActor, respectively. We intentionally make them private to prevent misuse.
// The purpose of these methods is to be aware of when the IPC system around this
// actor goes down: mIPCOpen is then set to false.
void AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
Release();
}
/// The normal way to destroy the actor.
///
/// This will asynchronously send a Destroy message to the parent actor, whom
@ -217,7 +200,6 @@ private:
TextureData* mTextureData;
Atomic<bool> mDestroyed;
bool mMainThreadOnly;
bool mIPCOpen;
bool mOwnsTextureData;
bool mOwnerCalledDestroy;
@ -255,8 +237,6 @@ void
TextureChild::ActorDestroy(ActorDestroyReason why)
{
AUTO_PROFILER_LABEL("TextureChild::ActorDestroy", GRAPHICS);
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
if (mTextureData) {
DestroyTextureData(mTextureData, GetAllocator(), mOwnsTextureData, mMainThreadOnly);
@ -744,16 +724,15 @@ TextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
PTextureChild*
TextureClient::CreateIPDLActor()
{
TextureChild* c = new TextureChild();
c->AddIPDLReference();
return c;
RefPtr<TextureChild> c = new TextureChild();
return c.forget().take();
}
// static
bool
TextureClient::DestroyIPDLActor(PTextureChild* actor)
{
static_cast<TextureChild*>(actor)->ReleaseIPDLReference();
RefPtr<TextureChild> tc = dont_AddRef(static_cast<TextureChild*>(actor));
return true;
}

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

@ -33,7 +33,9 @@ public:
*/
void Destroy();
bool IPCOpen() const { return mIPCOpen && !mDestroyed; }
bool IPCOpen() const {
return mozilla::ipc::IProtocol::IPCOpen() && !mDestroyed;
}
bool IsDestroyed() const { return mDestroyed; }
void SetForwarder(ShadowLayerForwarder* aForwarder)
@ -50,7 +52,6 @@ public:
protected:
explicit LayerTransactionChild(const LayersId& aId)
: mForwarder(nullptr)
, mIPCOpen(false)
, mDestroyed(false)
, mId(aId)
{}
@ -59,19 +60,14 @@ protected:
void ActorDestroy(ActorDestroyReason why) override;
void AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == true);
mIPCOpen = false;
Release();
}
friend class CompositorBridgeChild;
ShadowLayerForwarder* mForwarder;
bool mIPCOpen;
bool mDestroyed;
LayersId mId;
};

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

@ -58,7 +58,6 @@ LayerTransactionParent::LayerTransactionParent(HostLayerManager* aManager,
, mVsyncRate(aVsyncRate)
, mPendingTransaction{0}
, mDestroyed(false)
, mIPCOpen(false)
, mUpdateHitTestingTree(false)
{
MOZ_ASSERT(mId.IsValid());
@ -884,7 +883,7 @@ LayerTransactionParent::AllocShmem(size_t aSize,
ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem)
{
if (!mIPCOpen || mDestroyed) {
if (!IPCOpen() || mDestroyed) {
return false;
}
return PLayerTransactionParent::AllocShmem(aSize, aType, aShmem);
@ -895,7 +894,7 @@ LayerTransactionParent::AllocUnsafeShmem(size_t aSize,
ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem)
{
if (!mIPCOpen || mDestroyed) {
if (!IPCOpen() || mDestroyed) {
return false;
}
@ -905,7 +904,7 @@ LayerTransactionParent::AllocUnsafeShmem(size_t aSize,
void
LayerTransactionParent::DeallocShmem(ipc::Shmem& aShmem)
{
if (!mIPCOpen || mDestroyed) {
if (!IPCOpen() || mDestroyed) {
return;
}
PLayerTransactionParent::DeallocShmem(aShmem);

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

@ -57,6 +57,8 @@ public:
LayersId GetId() const { return mId; }
Layer* GetRoot() const { return mRoot; }
bool IPCOpen() const override { return mozilla::ipc::IProtocol::IPCOpen(); }
LayersObserverEpoch GetChildEpoch() const { return mChildEpoch; }
bool ShouldParentObserveEpoch();
@ -154,13 +156,9 @@ protected:
bool Attach(Layer* aLayer, CompositableHost* aCompositable, bool aIsAsyncVideo);
void AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == true);
mIPCOpen = false;
Release();
}
friend class CompositorBridgeParent;
@ -217,7 +215,6 @@ private:
// transactions posted by the child.
bool mDestroyed;
bool mIPCOpen;
// This is set during RecvUpdate to track whether we'll need to update
// APZ's hit test regions.

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

@ -29,7 +29,6 @@ WebRenderBridgeChild::WebRenderBridgeChild(const wr::PipelineId& aPipelineId)
, mResourceId(0)
, mPipelineId(aPipelineId)
, mManager(nullptr)
, mIPCOpen(false)
, mDestroyed(false)
, mFontKeysDeleted(0)
, mFontInstanceKeysDeleted(0)

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

@ -113,7 +113,9 @@ public:
* to be sent from the parent side.
*/
void Destroy(bool aIsSync);
bool IPCOpen() const { return mIPCOpen && !mDestroyed; }
bool IPCOpen() const {
return mozilla::ipc::IProtocol::IPCOpen() && !mDestroyed;
}
bool IsDestroyed() const { return mDestroyed; }
uint32_t GetNextResourceId() { return ++mResourceId; }
@ -213,13 +215,9 @@ private:
mozilla::ipc::IPCResult RecvWrReleasedImages(nsTArray<wr::ExternalImageKeyPair>&& aPairs) override;
void AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == true);
mIPCOpen = false;
Release();
}
@ -235,7 +233,6 @@ private:
wr::PipelineId mPipelineId;
WebRenderLayerManager* mManager;
bool mIPCOpen;
bool mDestroyed;
uint32_t mFontKeysDeleted;

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

@ -20,7 +20,6 @@ namespace gfx {
VRLayerChild::VRLayerChild()
: mCanvasElement(nullptr)
, mIPCOpen(false)
, mLastSubmittedFrameId(0)
{
MOZ_COUNT_CTOR(VRLayerChild);
@ -112,7 +111,7 @@ VRLayerChild::SubmitFrame(const VRDisplayInfo& aDisplayInfo)
bool
VRLayerChild::IsIPCOpen()
{
return mIPCOpen;
return IPCOpen();
}
void
@ -122,12 +121,6 @@ VRLayerChild::ClearSurfaces()
mLastFrameTexture = nullptr;
}
void
VRLayerChild::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}
// static
PVRLayerChild*
VRLayerChild::CreateIPDLActor()
@ -147,13 +140,10 @@ VRLayerChild::DestroyIPDLActor(PVRLayerChild* actor)
void
VRLayerChild::AddIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
mIPCOpen = true;
AddRef();
}
void
VRLayerChild::ReleaseIPDLReference() {
MOZ_ASSERT(mIPCOpen == false);
Release();
}

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

@ -44,10 +44,8 @@ private:
VRLayerChild();
virtual ~VRLayerChild();
void ClearSurfaces();
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
RefPtr<dom::HTMLCanvasElement> mCanvasElement;
bool mIPCOpen;
// AddIPDLReference and ReleaseIPDLReference are only to be called by CreateIPDLActor
// and DestroyIPDLActor, respectively. We intentionally make them private to prevent misuse.

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

@ -15,8 +15,7 @@ using namespace layers;
namespace gfx {
VRLayerParent::VRLayerParent(uint32_t aVRDisplayID, const uint32_t aGroup)
: mIPCOpen(true)
, mVRDisplayID(aVRDisplayID)
: mVRDisplayID(aVRDisplayID)
, mGroup(aGroup)
{
}
@ -33,12 +32,6 @@ VRLayerParent::RecvDestroy()
return IPC_OK();
}
void
VRLayerParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}
void
VRLayerParent::Destroy()
{
@ -53,7 +46,7 @@ VRLayerParent::Destroy()
mVRDisplayID = 0;
}
if (mIPCOpen) {
if (IPCOpen()) {
Unused << PVRLayerParent::Send__delete__(this);
}
}

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

@ -29,13 +29,9 @@ public:
uint32_t GetDisplayID() const { return mVRDisplayID; }
uint32_t GetGroup() const { return mGroup; }
protected:
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
virtual ~VRLayerParent();
void Destroy();
bool mIPCOpen;
uint32_t mVRDisplayID;
gfx::Rect mLeftEyeRect;
gfx::Rect mRightEyeRect;

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

@ -68,7 +68,6 @@ CookieServiceChild::CookieServiceChild()
, mThirdPartySession(false)
, mThirdPartyNonsecureSession(false)
, mLeaveSecureAlone(true)
, mIPCOpen(false)
{
NS_ASSERTION(IsNeckoChild(), "not a child process");
@ -86,8 +85,6 @@ CookieServiceChild::CookieServiceChild()
// Create a child PCookieService actor.
gNeckoChild->SendPCookieServiceConstructor(this);
mIPCOpen = true;
mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
NS_ASSERTION(mTLDService, "couldn't get TLDService");
@ -156,16 +153,10 @@ CookieServiceChild::~CookieServiceChild()
gCookieService = nullptr;
}
void
CookieServiceChild::ActorDestroy(ActorDestroyReason why)
{
mIPCOpen = false;
}
void
CookieServiceChild::TrackCookieLoad(nsIChannel *aChannel)
{
if (!mIPCOpen) {
if (!IPCOpen()) {
return;
}
@ -652,7 +643,7 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
}
// Asynchronously call the parent.
if (mIPCOpen) {
if (IPCOpen()) {
SendSetCookieString(hostURIParams, channelURIParams,
isForeign, isTrackingResource,
firstPartyStorageAccessGranted, cookieString,

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

@ -116,8 +116,6 @@ protected:
mozilla::ipc::IPCResult RecvAddCookie(const CookieStruct &aCookie,
const OriginAttributes &aAttrs) override;
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
CookiesMap mCookiesMap;
nsCOMPtr<nsITimer> mCookieTimer;
nsCOMPtr<mozIThirdPartyUtil> mThirdPartyUtil;
@ -126,7 +124,6 @@ protected:
bool mThirdPartySession;
bool mThirdPartyNonsecureSession;
bool mLeaveSecureAlone;
bool mIPCOpen;
};
} // namespace net

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

@ -215,7 +215,7 @@ public:
NS_IMETHOD Run() override
{
if (mDnsRequest->mIPCOpen) {
if (mDnsRequest->IPCOpen()) {
// Send request to Parent process.
mDnsRequest->SendCancelDNSRequest(mDnsRequest->mHost,
mDnsRequest->mType,
@ -247,7 +247,6 @@ DNSRequestChild::DNSRequestChild(const nsACString &aHost,
, mType(aType)
, mOriginAttributes(aOriginAttributes)
, mFlags(aFlags)
, mIPCOpen(false)
{
}
@ -278,7 +277,6 @@ DNSRequestChild::StartRequest()
// Send request to Parent process.
gNeckoChild->SendPDNSRequestConstructor(this, mHost, mOriginAttributes,
mFlags);
mIPCOpen = true;
// IPDL holds a reference until IPDL channel gets destroyed
AddIPDLReference();
@ -302,7 +300,6 @@ DNSRequestChild::CallOnLookupByTypeComplete()
mozilla::ipc::IPCResult
DNSRequestChild::RecvLookupCompleted(const DNSRequestResponse& reply)
{
mIPCOpen = false;
MOZ_ASSERT(mListener);
switch (reply.type()) {
@ -371,12 +368,6 @@ DNSRequestChild::ReleaseIPDLReference()
Release();
}
void
DNSRequestChild::ActorDestroy(ActorDestroyReason why)
{
mIPCOpen = false;
}
//-----------------------------------------------------------------------------
// DNSRequestChild::nsISupports
//-----------------------------------------------------------------------------
@ -391,7 +382,7 @@ NS_IMPL_ISUPPORTS(DNSRequestChild,
NS_IMETHODIMP
DNSRequestChild::Cancel(nsresult reason)
{
if(mIPCOpen) {
if(IPCOpen()) {
// We can only do IPDL on the main thread
nsCOMPtr<nsIRunnable> runnable = new CancelDNSRequestEvent(this, reason);
SystemGroup::Dispatch(TaskCategory::Other, runnable.forget());

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

@ -47,7 +47,6 @@ protected:
virtual ~DNSRequestChild() {}
virtual mozilla::ipc::IPCResult RecvLookupCompleted(const DNSRequestResponse& reply) override;
virtual void ActorDestroy(ActorDestroyReason why) override;
nsCOMPtr<nsIDNSListener> mListener;
nsCOMPtr<nsIEventTarget> mTarget;
@ -63,7 +62,6 @@ protected:
uint16_t mType;
const OriginAttributes mOriginAttributes;
uint16_t mFlags;
bool mIPCOpen;
};
} // namespace net

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

@ -17,7 +17,6 @@ NS_IMPL_ISUPPORTS_INHERITED(DataChannelChild, nsDataChannel, nsIChildChannel)
DataChannelChild::DataChannelChild(nsIURI* aURI)
: nsDataChannel(aURI)
, mIPCOpen(false)
{
}
@ -55,7 +54,7 @@ DataChannelChild::CompleteRedirectSetup(nsIStreamListener *aListener,
return rv;
}
if (mIPCOpen) {
if (IPCOpen()) {
Unused << Send__delete__(this);
}
return NS_OK;
@ -65,14 +64,11 @@ void
DataChannelChild::AddIPDLReference()
{
AddRef();
mIPCOpen = true;
}
void
DataChannelChild::ActorDestroy(ActorDestroyReason why)
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
Release();
}

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

@ -33,8 +33,6 @@ private:
~DataChannelChild() = default;
void AddIPDLReference();
bool mIPCOpen;
};
} // namespace net

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

@ -17,7 +17,6 @@ NS_IMPL_ISUPPORTS_INHERITED(FileChannelChild, nsFileChannel, nsIChildChannel)
FileChannelChild::FileChannelChild(nsIURI *uri)
: nsFileChannel(uri)
, mIPCOpen(false)
{
}
@ -55,7 +54,7 @@ FileChannelChild::CompleteRedirectSetup(nsIStreamListener *listener,
return rv;
}
if (mIPCOpen) {
if (IPCOpen()) {
Unused << Send__delete__(this);
}
@ -66,14 +65,11 @@ void
FileChannelChild::AddIPDLReference()
{
AddRef();
mIPCOpen = true;
}
void
FileChannelChild::ActorDestroy(ActorDestroyReason why)
{
MOZ_ASSERT(mIPCOpen);
mIPCOpen = false;
Release();
}

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

@ -33,8 +33,6 @@ private:
~FileChannelChild() = default;;
void AddIPDLReference();
bool mIPCOpen;
};
} // namespace net

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

@ -34,8 +34,7 @@ namespace mozilla {
namespace net {
FTPChannelChild::FTPChannelChild(nsIURI* uri)
: mIPCOpen(false)
, mUnknownDecoderInvolved(false)
: mUnknownDecoderInvolved(false)
, mCanceled(false)
, mSuspendCount(0)
, mIsPending(false)
@ -65,16 +64,12 @@ FTPChannelChild::~FTPChannelChild()
void
FTPChannelChild::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempt to retain more than one IPDL reference");
mIPCOpen = true;
AddRef();
}
void
FTPChannelChild::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempt to release nonexistent IPDL reference");
mIPCOpen = false;
Release();
}
@ -687,8 +682,9 @@ FTPChannelChild::DoFailedAsyncOpen(const nsresult& statusCode)
mListener = nullptr;
mListenerContext = nullptr;
if (mIPCOpen)
if (IPCOpen()) {
Send__delete__(this);
}
}
class FTPFlushedForDiversionEvent : public NeckoTargetChannelEvent<FTPChannelChild>
@ -763,8 +759,9 @@ FTPChannelChild::RecvDeleteSelf()
void
FTPChannelChild::DoDeleteSelf()
{
if (mIPCOpen)
if (IPCOpen()) {
Send__delete__(this);
}
}
NS_IMETHODIMP
@ -776,15 +773,16 @@ FTPChannelChild::Cancel(nsresult status)
mCanceled = true;
mStatus = status;
if (mIPCOpen)
if (IPCOpen()) {
SendCancel(status);
}
return NS_OK;
}
NS_IMETHODIMP
FTPChannelChild::Suspend()
{
NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(IPCOpen(), NS_ERROR_NOT_AVAILABLE);
LOG(("FTPChannelChild::Suspend [this=%p]\n", this));
@ -803,7 +801,7 @@ FTPChannelChild::Suspend()
NS_IMETHODIMP
FTPChannelChild::Resume()
{
NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(IPCOpen(), NS_ERROR_NOT_AVAILABLE);
LOG(("FTPChannelChild::Resume [this=%p]\n", this));
@ -905,7 +903,7 @@ FTPChannelChild::DivertToParent(ChannelDiverterChild **aChild)
// We must fail DivertToParent() if there's no parent end of the channel (and
// won't be!) due to early failure.
if (NS_FAILED(mStatus) && !mIPCOpen) {
if (NS_FAILED(mStatus) && !IPCOpen()) {
return mStatus;
}

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

@ -133,7 +133,6 @@ protected:
private:
nsCOMPtr<nsIInputStream> mUploadStream;
bool mIPCOpen;
RefPtr<ChannelEventQueue> mEventQ;
// If nsUnknownDecoder is involved we queue onDataAvailable (and possibly

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

@ -14,7 +14,7 @@ NS_IMETHODIMP_(MozExternalRefCountType) AltDataOutputStreamChild::Release()
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "AltDataOutputStreamChild");
if (mRefCnt == 1 && mIPCOpen) {
if (mRefCnt == 1 && IPCOpen()) {
// The only reference left is the IPDL one. After the parent replies back
// with a DeleteSelf message, the child will call Send__delete__(this),
// decrementing the ref count and triggering the destructor.
@ -36,8 +36,7 @@ NS_INTERFACE_MAP_BEGIN(AltDataOutputStreamChild)
NS_INTERFACE_MAP_END
AltDataOutputStreamChild::AltDataOutputStreamChild()
: mIPCOpen(false)
, mError(NS_OK)
: mError(NS_OK)
{
MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
}
@ -45,16 +44,12 @@ AltDataOutputStreamChild::AltDataOutputStreamChild()
void
AltDataOutputStreamChild::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempt to retain more than one IPDL reference");
mIPCOpen = true;
AddRef();
}
void
AltDataOutputStreamChild::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempt to release nonexistent IPDL reference");
mIPCOpen = false;
Release();
}
@ -66,8 +61,7 @@ AltDataOutputStreamChild::WriteDataInChunks(const nsDependentCSubstring& data)
for (uint32_t i = 0; i < data.Length();
i = next, next = std::min(data.Length(), next + kChunkSize)) {
nsCString chunk(Substring(data, i, kChunkSize));
if (mIPCOpen && !SendWriteData(chunk)) {
mIPCOpen = false;
if (IPCOpen() && !SendWriteData(chunk)) {
return false;
}
}
@ -77,7 +71,7 @@ AltDataOutputStreamChild::WriteDataInChunks(const nsDependentCSubstring& data)
NS_IMETHODIMP
AltDataOutputStreamChild::Close()
{
if (!mIPCOpen) {
if (!IPCOpen()) {
return NS_ERROR_NOT_AVAILABLE;
}
if (NS_FAILED(mError)) {
@ -90,7 +84,7 @@ AltDataOutputStreamChild::Close()
NS_IMETHODIMP
AltDataOutputStreamChild::Flush()
{
if (!mIPCOpen) {
if (!IPCOpen()) {
return NS_ERROR_NOT_AVAILABLE;
}
if (NS_FAILED(mError)) {
@ -104,7 +98,7 @@ AltDataOutputStreamChild::Flush()
NS_IMETHODIMP
AltDataOutputStreamChild::Write(const char * aBuf, uint32_t aCount, uint32_t *_retval)
{
if (!mIPCOpen) {
if (!IPCOpen()) {
return NS_ERROR_NOT_AVAILABLE;
}
if (NS_FAILED(mError)) {

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

@ -34,7 +34,6 @@ private:
// Sends data to the parent process in 256k chunks.
bool WriteDataInChunks(const nsDependentCSubstring& data);
bool mIPCOpen;
// If there was an error opening the output stream or writing to it on the
// parent side, this will be set to the error code. We check it before we
// write so we can report an error to the consumer.

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

@ -16,7 +16,6 @@ NS_IMPL_ISUPPORTS0(AltDataOutputStreamParent)
AltDataOutputStreamParent::AltDataOutputStreamParent(nsIOutputStream* aStream)
: mOutputStream(aStream)
, mStatus(NS_OK)
, mIPCOpen(true)
{
MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
}
@ -30,7 +29,7 @@ mozilla::ipc::IPCResult
AltDataOutputStreamParent::RecvWriteData(const nsCString& data)
{
if (NS_FAILED(mStatus)) {
if (mIPCOpen) {
if (IPCOpen()) {
Unused << SendError(mStatus);
}
return IPC_OK();
@ -40,7 +39,7 @@ AltDataOutputStreamParent::RecvWriteData(const nsCString& data)
if (mOutputStream) {
rv = mOutputStream->Write(data.BeginReading(), data.Length(), &n);
MOZ_ASSERT(n == data.Length() || NS_FAILED(rv));
if (NS_FAILED(rv) && mIPCOpen) {
if (NS_FAILED(rv) && IPCOpen()) {
Unused << SendError(rv);
}
}
@ -51,7 +50,7 @@ mozilla::ipc::IPCResult
AltDataOutputStreamParent::RecvClose()
{
if (NS_FAILED(mStatus)) {
if (mIPCOpen) {
if (IPCOpen()) {
Unused << SendError(mStatus);
}
return IPC_OK();
@ -59,7 +58,7 @@ AltDataOutputStreamParent::RecvClose()
nsresult rv;
if (mOutputStream) {
rv = mOutputStream->Close();
if (NS_FAILED(rv) && mIPCOpen) {
if (NS_FAILED(rv) && IPCOpen()) {
Unused << SendError(rv);
}
mOutputStream = nullptr;
@ -67,16 +66,9 @@ AltDataOutputStreamParent::RecvClose()
return IPC_OK();
}
void
AltDataOutputStreamParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}
mozilla::ipc::IPCResult
AltDataOutputStreamParent::RecvDeleteSelf()
{
mIPCOpen = false;
Unused << SendDeleteSelf();
return IPC_OK();
}

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

@ -33,7 +33,6 @@ public:
// Called when AltDataOutputStreamChild::Close() is
// Closes and nulls the output stream.
virtual mozilla::ipc::IPCResult RecvClose() override;
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
// Sets an error that will be reported to the content process.
void SetError(nsresult status) { mStatus = status; }
@ -45,7 +44,6 @@ private:
// In case any error occurs mStatus will be != NS_OK, and this status code will
// be sent to the content process asynchronously.
nsresult mStatus;
bool mIPCOpen;
};
} // namespace net

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

@ -2441,10 +2441,11 @@ HttpChannelChild::OnRedirectVerifyCallback(nsresult result)
ChildLoadInfoForwarderArgs loadInfoForwarder;
LoadInfoToChildLoadInfoForwarder(newChannelLoadInfo, &loadInfoForwarder);
if (mIPCOpen)
if (mIPCOpen) {
SendRedirect2Verify(result, *headerTuples, loadInfoForwarder, loadFlags,
referrerPolicy, referrerURI, redirectURI,
corsPreflightArgs, chooseAppcache);
}
return NS_OK;
}

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

@ -29,7 +29,6 @@ WebSocketChannelParent::WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvi
uint32_t aSerial)
: mAuthProvider(aAuthProvider)
, mLoadContext(aLoadContext)
, mIPCOpen(true)
, mSerial(aSerial)
{
// Websocket channels can't have a private browsing override
@ -46,7 +45,7 @@ WebSocketChannelParent::RecvDeleteSelf()
mChannel = nullptr;
mAuthProvider = nullptr;
IProtocol* mgr = Manager();
if (mIPCOpen && !Send__delete__(this)) {
if (IPCOpen() && !Send__delete__(this)) {
return IPC_FAIL_NO_REASON(mgr);
}
return IPC_OK();
@ -222,7 +221,7 @@ WebSocketChannelParent::OnStart(nsISupports *aContext)
channel->GetEffectiveURL(effectiveURL);
encrypted = channel->IsEncrypted();
}
if (!mIPCOpen || !SendOnStart(protocol, extensions, effectiveURL, encrypted)) {
if (!IPCOpen() || !SendOnStart(protocol, extensions, effectiveURL, encrypted)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -232,7 +231,7 @@ NS_IMETHODIMP
WebSocketChannelParent::OnStop(nsISupports *aContext, nsresult aStatusCode)
{
LOG(("WebSocketChannelParent::OnStop() %p\n", this));
if (!mIPCOpen || !SendOnStop(aStatusCode)) {
if (!IPCOpen() || !SendOnStop(aStatusCode)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -242,7 +241,7 @@ NS_IMETHODIMP
WebSocketChannelParent::OnMessageAvailable(nsISupports *aContext, const nsACString& aMsg)
{
LOG(("WebSocketChannelParent::OnMessageAvailable() %p\n", this));
if (!mIPCOpen || !SendOnMessageAvailable(nsCString(aMsg))) {
if (!IPCOpen() || !SendOnMessageAvailable(nsCString(aMsg))) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -252,7 +251,7 @@ NS_IMETHODIMP
WebSocketChannelParent::OnBinaryMessageAvailable(nsISupports *aContext, const nsACString& aMsg)
{
LOG(("WebSocketChannelParent::OnBinaryMessageAvailable() %p\n", this));
if (!mIPCOpen || !SendOnBinaryMessageAvailable(nsCString(aMsg))) {
if (!IPCOpen() || !SendOnBinaryMessageAvailable(nsCString(aMsg))) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -262,7 +261,7 @@ NS_IMETHODIMP
WebSocketChannelParent::OnAcknowledge(nsISupports *aContext, uint32_t aSize)
{
LOG(("WebSocketChannelParent::OnAcknowledge() %p\n", this));
if (!mIPCOpen || !SendOnAcknowledge(aSize)) {
if (!IPCOpen() || !SendOnAcknowledge(aSize)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -273,7 +272,7 @@ WebSocketChannelParent::OnServerClose(nsISupports *aContext,
uint16_t code, const nsACString & reason)
{
LOG(("WebSocketChannelParent::OnServerClose() %p\n", this));
if (!mIPCOpen || !SendOnServerClose(code, nsCString(reason))) {
if (!IPCOpen() || !SendOnServerClose(code, nsCString(reason))) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -290,8 +289,6 @@ WebSocketChannelParent::ActorDestroy(ActorDestroyReason why)
Unused << mChannel->Close(nsIWebSocketChannel::CLOSE_GOING_AWAY,
NS_LITERAL_CSTRING("Child was killed"));
}
mIPCOpen = false;
}
//-----------------------------------------------------------------------------

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

@ -61,7 +61,6 @@ class WebSocketChannelParent : public PWebSocketParent,
nsCOMPtr<nsIAuthPromptProvider> mAuthProvider;
nsCOMPtr<nsIWebSocketChannel> mChannel;
nsCOMPtr<nsILoadContext> mLoadContext;
bool mIPCOpen;
uint32_t mSerial;
};

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

@ -47,7 +47,6 @@ WyciwygChannelChild::WyciwygChannelChild(nsIEventTarget *aNeckoTarget)
, mContentLength(-1)
, mCharsetSource(kCharsetUninitialized)
, mState(WCC_NEW)
, mIPCOpen(false)
, mSentAppData(false)
{
LOG(("Creating WyciwygChannelChild @%p\n", this));
@ -74,16 +73,12 @@ WyciwygChannelChild::~WyciwygChannelChild()
void
WyciwygChannelChild::AddIPDLReference()
{
MOZ_ASSERT(!mIPCOpen, "Attempt to retain more than one IPDL reference");
mIPCOpen = true;
AddRef();
}
void
WyciwygChannelChild::ReleaseIPDLReference()
{
MOZ_ASSERT(mIPCOpen, "Attempt to release nonexistent IPDL reference");
mIPCOpen = false;
Release();
}
@ -328,8 +323,9 @@ WyciwygChannelChild::OnStopRequest(const nsresult& statusCode)
mProgressSink = nullptr;
}
if (mIPCOpen)
if (IPCOpen()) {
PWyciwygChannelChild::Send__delete__(this);
}
}
class WyciwygCancelEvent : public NeckoTargetChannelEvent<WyciwygChannelChild>
@ -373,8 +369,9 @@ void WyciwygChannelChild::CancelEarly(const nsresult& statusCode)
mListener = nullptr;
mListenerContext = nullptr;
if (mIPCOpen)
if (IPCOpen()) {
PWyciwygChannelChild::Send__delete__(this);
}
}
//-----------------------------------------------------------------------------
@ -409,8 +406,9 @@ WyciwygChannelChild::Cancel(nsresult aStatus)
mCanceled = true;
mStatus = aStatus;
if (mIPCOpen)
if (IPCOpen()) {
SendCancel(aStatus);
}
return NS_OK;
}
@ -753,8 +751,9 @@ WyciwygChannelChild::CloseCacheEntry(nsresult reason)
SendCloseCacheEntry(reason);
mState = WCC_ONCLOSED;
if (mIPCOpen)
if (IPCOpen()) {
PWyciwygChannelChild::Send__delete__(this);
}
return NS_OK;
}

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

@ -104,7 +104,6 @@ private:
// FIXME: replace with IPDL states (bug 536319)
enum WyciwygChannelChildState mState;
bool mIPCOpen;
bool mSentAppData;
RefPtr<ChannelEventQueue> mEventQ;

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

@ -213,7 +213,6 @@ PSMContentStreamListener::ImportCertificate()
PSMContentDownloaderParent::PSMContentDownloaderParent(uint32_t type)
: PSMContentStreamListener(type)
, mIPCOpen(true)
{
}
@ -248,7 +247,7 @@ PSMContentDownloaderParent::RecvOnStopRequest(const nsresult& code)
ImportCertificate();
}
if (mIPCOpen) {
if (IPCOpen()) {
mozilla::Unused << Send__delete__(this);
}
return IPC_OK();
@ -259,7 +258,7 @@ PSMContentDownloaderParent::OnStopRequest(nsIRequest* request, nsISupports* cont
{
nsresult rv = PSMContentStreamListener::OnStopRequest(request, context, code);
if (mIPCOpen) {
if (IPCOpen()) {
mozilla::Unused << Send__delete__(this);
}
return rv;
@ -275,12 +274,6 @@ PSMContentDownloaderParent::RecvDivertToParentUsing(mozilla::net::PChannelDivert
return IPC_OK();
}
void
PSMContentDownloaderParent::ActorDestroy(ActorDestroyReason why)
{
mIPCOpen = false;
}
/* ------------------------
* PSMContentDownloaderChild
* ------------------------ */

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

@ -67,9 +67,6 @@ public:
protected:
virtual ~PSMContentDownloaderParent();
virtual void ActorDestroy(ActorDestroyReason why) override;
bool mIPCOpen;
};
// Child actor for importing a cert.

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

@ -46,14 +46,8 @@ LoginReputationParent::OnComplete(nsresult aResult,
LR_LOG(("OnComplete() [verdict=%s]",
LoginReputationService::VerdictTypeToString(aVerdict).get()));
if (mIPCOpen) {
if (IPCOpen()) {
Unused << Send__delete__(this);
}
return NS_OK;
}
void
LoginReputationParent::ActorDestroy(ActorDestroyReason aWhy)
{
mIPCOpen = false;
}

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

@ -24,11 +24,8 @@ public:
mozilla::ipc::IPCResult QueryReputation(nsIURI* aURI);
void ActorDestroy(ActorDestroyReason aWhy) override;
private:
~LoginReputationParent() = default;
bool mIPCOpen = true;
};
} // namespace dom