зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1824465 - Part 18: Make PSocketProcess refcounted, r=necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D173733
This commit is contained in:
Родитель
2adcc178cd
Коммит
373efd85f0
|
@ -88,7 +88,7 @@ struct SocketPorcessInitAttributes {
|
|||
FileDescriptor? mSandboxBroker;
|
||||
};
|
||||
|
||||
[ManualDealloc, NeedsOtherPid]
|
||||
[NeedsOtherPid]
|
||||
sync protocol PSocketProcess
|
||||
{
|
||||
manages PDNSRequest;
|
||||
|
|
|
@ -295,9 +295,15 @@ mozilla::ipc::IPCResult SocketProcessChild::RecvInitSocketProcessBridgeParent(
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mSocketProcessBridgeParentMap.Contains(aContentProcessId));
|
||||
|
||||
mSocketProcessBridgeParentMap.InsertOrUpdate(
|
||||
aContentProcessId, MakeRefPtr<SocketProcessBridgeParent>(
|
||||
aContentProcessId, std::move(aEndpoint)));
|
||||
if (NS_WARN_IF(!aEndpoint.IsValid())) {
|
||||
return IPC_FAIL(this, "invalid endpoint");
|
||||
}
|
||||
|
||||
auto bridge = MakeRefPtr<SocketProcessBridgeParent>(aContentProcessId);
|
||||
MOZ_ALWAYS_TRUE(aEndpoint.Bind(bridge));
|
||||
|
||||
mSocketProcessBridgeParentMap.InsertOrUpdate(aContentProcessId,
|
||||
std::move(bridge));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class BackgroundDataBridgeParent;
|
|||
// This is allocated and kept alive by SocketProcessImpl.
|
||||
class SocketProcessChild final : public PSocketProcessChild {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SocketProcessChild)
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SocketProcessChild, final)
|
||||
|
||||
SocketProcessChild();
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ void SocketProcessHost::InitAfterConnect(bool aSucceeded) {
|
|||
return;
|
||||
}
|
||||
|
||||
mSocketProcessParent = MakeUnique<SocketProcessParent>(this);
|
||||
mSocketProcessParent = MakeRefPtr<SocketProcessParent>(this);
|
||||
DebugOnly<bool> rv = TakeInitialEndpoint().Bind(mSocketProcessParent.get());
|
||||
MOZ_ASSERT(rv);
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ class SocketProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
|
|||
enum class LaunchPhase { Unlaunched, Waiting, Complete };
|
||||
LaunchPhase mLaunchPhase;
|
||||
|
||||
UniquePtr<SocketProcessParent> mSocketProcessParent;
|
||||
RefPtr<SocketProcessParent> mSocketProcessParent;
|
||||
// mShutdownRequested is set to true only when Shutdown() is called.
|
||||
// If mShutdownRequested is false and the IPC channel is closed,
|
||||
// OnProcessUnexpectedShutdown will be invoked.
|
||||
|
|
|
@ -67,10 +67,10 @@ bool SocketProcessImpl::Init(int aArgc, char* aArgv[]) {
|
|||
return false;
|
||||
}
|
||||
|
||||
return mSocketProcessChild.Init(TakeInitialEndpoint(), *parentBuildID);
|
||||
return mSocketProcessChild->Init(TakeInitialEndpoint(), *parentBuildID);
|
||||
}
|
||||
|
||||
void SocketProcessImpl::CleanUp() { mSocketProcessChild.CleanUp(); }
|
||||
void SocketProcessImpl::CleanUp() { mSocketProcessChild->CleanUp(); }
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -26,7 +26,7 @@ class SocketProcessImpl final : public mozilla::ipc::ProcessChild {
|
|||
void CleanUp() override;
|
||||
|
||||
private:
|
||||
SocketProcessChild mSocketProcessChild;
|
||||
RefPtr<SocketProcessChild> mSocketProcessChild = new SocketProcessChild;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -293,18 +293,18 @@ mozilla::ipc::IPCResult SocketProcessParent::RecvCachePushCheck(
|
|||
class DeferredDeleteSocketProcessParent : public Runnable {
|
||||
public:
|
||||
explicit DeferredDeleteSocketProcessParent(
|
||||
UniquePtr<SocketProcessParent>&& aParent)
|
||||
RefPtr<SocketProcessParent>&& aParent)
|
||||
: Runnable("net::DeferredDeleteSocketProcessParent"),
|
||||
mParent(std::move(aParent)) {}
|
||||
|
||||
NS_IMETHODIMP Run() override { return NS_OK; }
|
||||
|
||||
private:
|
||||
UniquePtr<SocketProcessParent> mParent;
|
||||
RefPtr<SocketProcessParent> mParent;
|
||||
};
|
||||
|
||||
/* static */
|
||||
void SocketProcessParent::Destroy(UniquePtr<SocketProcessParent>&& aParent) {
|
||||
void SocketProcessParent::Destroy(RefPtr<SocketProcessParent>&& aParent) {
|
||||
NS_DispatchToMainThread(
|
||||
new DeferredDeleteSocketProcessParent(std::move(aParent)));
|
||||
}
|
||||
|
|
|
@ -31,8 +31,9 @@ class SocketProcessParent final
|
|||
public:
|
||||
friend class SocketProcessHost;
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(SocketProcessParent, final)
|
||||
|
||||
explicit SocketProcessParent(SocketProcessHost* aHost);
|
||||
~SocketProcessParent();
|
||||
|
||||
static SocketProcessParent* GetSingleton();
|
||||
|
||||
|
@ -112,10 +113,12 @@ class SocketProcessParent final
|
|||
#endif // defined(XP_WIN)
|
||||
|
||||
private:
|
||||
~SocketProcessParent();
|
||||
|
||||
SocketProcessHost* mHost;
|
||||
UniquePtr<dom::MemoryReportRequestHost> mMemoryReportRequest;
|
||||
|
||||
static void Destroy(UniquePtr<SocketProcessParent>&& aParent);
|
||||
static void Destroy(RefPtr<SocketProcessParent>&& aParent);
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
Загрузка…
Ссылка в новой задаче