зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1513057 - P6: Create Background between content process and socket process r=dragana,mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D14348 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f13da4ca28
Коммит
621b98340a
|
@ -21,6 +21,12 @@ class ContentParent;
|
|||
|
||||
} // namespace dom
|
||||
|
||||
namespace net {
|
||||
|
||||
class SocketProcessImpl;
|
||||
|
||||
} // namespace net
|
||||
|
||||
namespace ipc {
|
||||
|
||||
class PBackgroundChild;
|
||||
|
@ -36,6 +42,10 @@ class PBackgroundChild;
|
|||
// create the actor if it doesn't exist yet. Thereafter (assuming success)
|
||||
// GetForCurrentThread() will return the same actor every time.
|
||||
//
|
||||
// GetOrCreateSocketActorForCurrentThread, which is like
|
||||
// GetOrCreateForCurrentThread, is used to get or create PBackground actor
|
||||
// between child process and socket process.
|
||||
//
|
||||
// CloseForCurrentThread() will close the current PBackground actor. Subsequent
|
||||
// calls to GetForCurrentThread will return null. CloseForCurrentThread() may
|
||||
// only be called exactly once for each thread-specific actor. Currently it is
|
||||
|
@ -46,6 +56,7 @@ class PBackgroundChild;
|
|||
class BackgroundChild final {
|
||||
friend class mozilla::dom::ContentChild;
|
||||
friend class mozilla::dom::ContentParent;
|
||||
friend class mozilla::net::SocketProcessImpl;
|
||||
|
||||
typedef mozilla::ipc::Transport Transport;
|
||||
|
||||
|
@ -60,6 +71,10 @@ class BackgroundChild final {
|
|||
// See above.
|
||||
static void CloseForCurrentThread();
|
||||
|
||||
// See above.
|
||||
static PBackgroundChild* GetOrCreateSocketActorForCurrentThread(
|
||||
nsIEventTarget* aMainEventTarget = nullptr);
|
||||
|
||||
private:
|
||||
// Only called by ContentChild or ContentParent.
|
||||
static void Startup();
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/dom/WorkerRef.h"
|
||||
#include "mozilla/ipc/ProtocolTypes.h"
|
||||
#include "mozilla/net/SocketProcessBridgeChild.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIEventTarget.h"
|
||||
|
@ -44,6 +45,8 @@
|
|||
#include "nsXPCOMPrivate.h"
|
||||
#include "prthread.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#ifdef RELEASE_OR_BETA
|
||||
#define THREADSAFETY_ASSERT MOZ_ASSERT
|
||||
#else
|
||||
|
@ -62,6 +65,7 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::ipc;
|
||||
using namespace mozilla::net;
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -73,6 +77,10 @@ class ChildImpl;
|
|||
|
||||
void AssertIsInMainProcess() { MOZ_ASSERT(XRE_IsParentProcess()); }
|
||||
|
||||
void AssertIsInMainOrSocketProcess() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsSocketProcess());
|
||||
}
|
||||
|
||||
void AssertIsOnMainThread() { THREADSAFETY_ASSERT(NS_IsMainThread()); }
|
||||
|
||||
void AssertIsNotOnMainThread() { THREADSAFETY_ASSERT(!NS_IsMainThread()); }
|
||||
|
@ -101,7 +109,7 @@ class ParentImpl final : public BackgroundParentImpl {
|
|||
|
||||
TimerCallbackClosure(nsIThread* aThread, nsTArray<ParentImpl*>* aLiveActors)
|
||||
: mThread(aThread), mLiveActors(aLiveActors) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aThread);
|
||||
MOZ_ASSERT(aLiveActors);
|
||||
|
@ -220,13 +228,12 @@ class ParentImpl final : public BackgroundParentImpl {
|
|||
mLiveActorArray(nullptr),
|
||||
mIsOtherProcessActor(true),
|
||||
mActorDestroyed(false) {
|
||||
AssertIsInMainProcess();
|
||||
MOZ_ASSERT((XRE_IsParentProcess() && aContent) || XRE_IsSocketProcess());
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aContent);
|
||||
}
|
||||
|
||||
~ParentImpl() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(!mContent);
|
||||
}
|
||||
|
@ -234,7 +241,7 @@ class ParentImpl final : public BackgroundParentImpl {
|
|||
void MainThreadActorDestroy();
|
||||
|
||||
void SetLiveActorArray(nsTArray<ParentImpl*>* aLiveActorArray) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aLiveActorArray);
|
||||
MOZ_ASSERT(!aLiveActorArray->Contains(this));
|
||||
|
@ -270,6 +277,7 @@ class ChildImpl final : public BackgroundChildImpl {
|
|||
// This is only modified on the main thread. It is the thread-local index that
|
||||
// we use to store the BackgroundChild for each thread.
|
||||
static unsigned int sThreadLocalIndex;
|
||||
static unsigned int sThreadLocalIndexForSocketProcess;
|
||||
|
||||
struct ThreadLocalInfo {
|
||||
ThreadLocalInfo()
|
||||
|
@ -292,6 +300,8 @@ class ChildImpl final : public BackgroundChildImpl {
|
|||
// thread info.
|
||||
static ThreadLocalInfo* sMainThreadInfo;
|
||||
|
||||
static ThreadLocalInfo* sMainThreadInfoForSocketProcess;
|
||||
|
||||
// This is only modified on the main thread. It prevents us from trying to
|
||||
// create the background thread after application shutdown has started.
|
||||
static bool sShutdownHasStarted;
|
||||
|
@ -308,6 +318,8 @@ class ChildImpl final : public BackgroundChildImpl {
|
|||
public:
|
||||
static void Shutdown();
|
||||
|
||||
static void ShutdownWithThreadLocalIndex(unsigned int aThreadLocalIndex);
|
||||
|
||||
void AssertIsOnOwningThread() {
|
||||
THREADSAFETY_ASSERT(mOwningEventTarget);
|
||||
|
||||
|
@ -357,13 +369,23 @@ class ChildImpl final : public BackgroundChildImpl {
|
|||
// Forwarded from BackgroundChild.
|
||||
static PBackgroundChild* GetForCurrentThread();
|
||||
|
||||
// Helper function for getting PBackgroundChild from thread info.
|
||||
static PBackgroundChild* GetFromThreadInfo(nsIEventTarget* aMainEventTarget,
|
||||
ThreadLocalInfo* aThreadLocalInfo);
|
||||
|
||||
// Forwarded from BackgroundChild.
|
||||
static PBackgroundChild* GetOrCreateForCurrentThread(
|
||||
nsIEventTarget* aMainEventTarget);
|
||||
|
||||
// Forwarded from BackgroundChild.
|
||||
static PBackgroundChild* GetOrCreateSocketActorForCurrentThread(
|
||||
nsIEventTarget* aMainEventTarget);
|
||||
|
||||
// Forwarded from BackgroundChild.
|
||||
static void CloseForCurrentThread();
|
||||
|
||||
static void CloseThreadWithIndex(unsigned int aThreadLocalIndex);
|
||||
|
||||
// Forwarded from BackgroundChildImpl.
|
||||
static BackgroundChildImpl::ThreadLocal* GetThreadLocalForCurrentThread();
|
||||
|
||||
|
@ -400,7 +422,7 @@ class ParentImpl::RequestMessageLoopRunnable final : public Runnable {
|
|||
: Runnable("Background::ParentImpl::RequestMessageLoopRunnable"),
|
||||
mTargetThread(aTargetThread),
|
||||
mMessageLoop(nullptr) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aTargetThread);
|
||||
}
|
||||
|
@ -415,7 +437,7 @@ class ParentImpl::ShutdownBackgroundThreadRunnable final : public Runnable {
|
|||
public:
|
||||
ShutdownBackgroundThreadRunnable()
|
||||
: Runnable("Background::ParentImpl::ShutdownBackgroundThreadRunnable") {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
}
|
||||
|
||||
|
@ -433,7 +455,7 @@ class ParentImpl::ForceCloseBackgroundActorsRunnable final : public Runnable {
|
|||
nsTArray<ParentImpl*>* aActorArray)
|
||||
: Runnable("Background::ParentImpl::ForceCloseBackgroundActorsRunnable"),
|
||||
mActorArray(aActorArray) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aActorArray);
|
||||
}
|
||||
|
@ -457,14 +479,14 @@ class ParentImpl::ConnectActorRunnable final : public Runnable {
|
|||
mActor(aActor),
|
||||
mEndpoint(std::move(aEndpoint)),
|
||||
mLiveActorArray(aLiveActorArray) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(mEndpoint.IsValid());
|
||||
MOZ_ASSERT(aLiveActorArray);
|
||||
}
|
||||
|
||||
private:
|
||||
~ConnectActorRunnable() { AssertIsInMainProcess(); }
|
||||
~ConnectActorRunnable() { AssertIsInMainOrSocketProcess(); }
|
||||
|
||||
NS_DECL_NSIRUNNABLE
|
||||
};
|
||||
|
@ -482,7 +504,7 @@ class ParentImpl::CreateActorHelper final : public Runnable {
|
|||
mMonitor("CreateActorHelper::mMonitor"),
|
||||
mMainThreadResultCode(NS_OK),
|
||||
mWaiting(true) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsNotOnMainThread();
|
||||
}
|
||||
|
||||
|
@ -491,7 +513,7 @@ class ParentImpl::CreateActorHelper final : public Runnable {
|
|||
nsCOMPtr<nsIThread>& aThread);
|
||||
|
||||
private:
|
||||
~CreateActorHelper() { AssertIsInMainProcess(); }
|
||||
~CreateActorHelper() { AssertIsInMainOrSocketProcess(); }
|
||||
|
||||
nsresult RunOnMainThread();
|
||||
|
||||
|
@ -532,10 +554,12 @@ class ChildImpl::SendInitBackgroundRunnable final : public CancelableRunnable {
|
|||
Endpoint<PBackgroundParent> mParent;
|
||||
mozilla::Mutex mMutex;
|
||||
bool mSentInitBackground;
|
||||
std::function<void(Endpoint<PBackgroundParent>&& aParent)> mSendInitfunc;
|
||||
|
||||
public:
|
||||
static already_AddRefed<SendInitBackgroundRunnable> Create(
|
||||
Endpoint<PBackgroundParent>&& aParent);
|
||||
Endpoint<PBackgroundParent>&& aParent,
|
||||
std::function<void(Endpoint<PBackgroundParent>&& aParent)>&& aFunc);
|
||||
|
||||
void ClearEventTarget() {
|
||||
mWorkerRef = nullptr;
|
||||
|
@ -545,12 +569,15 @@ class ChildImpl::SendInitBackgroundRunnable final : public CancelableRunnable {
|
|||
}
|
||||
|
||||
private:
|
||||
explicit SendInitBackgroundRunnable(Endpoint<PBackgroundParent>&& aParent)
|
||||
explicit SendInitBackgroundRunnable(
|
||||
Endpoint<PBackgroundParent>&& aParent,
|
||||
std::function<void(Endpoint<PBackgroundParent>&& aParent)>&& aFunc)
|
||||
: CancelableRunnable("Background::ChildImpl::SendInitBackgroundRunnable"),
|
||||
mOwningEventTarget(GetCurrentThreadSerialEventTarget()),
|
||||
mParent(std::move(aParent)),
|
||||
mMutex("SendInitBackgroundRunnable::mMutex"),
|
||||
mSentInitBackground(false) {}
|
||||
mSentInitBackground(false),
|
||||
mSendInitfunc(std::move(aFunc)) {}
|
||||
|
||||
~SendInitBackgroundRunnable() {}
|
||||
|
||||
|
@ -631,6 +658,12 @@ PBackgroundChild* BackgroundChild::GetOrCreateForCurrentThread(
|
|||
return ChildImpl::GetOrCreateForCurrentThread(aMainEventTarget);
|
||||
}
|
||||
|
||||
// static
|
||||
PBackgroundChild* BackgroundChild::GetOrCreateSocketActorForCurrentThread(
|
||||
nsIEventTarget* aMainEventTarget) {
|
||||
return ChildImpl::GetOrCreateSocketActorForCurrentThread(aMainEventTarget);
|
||||
}
|
||||
|
||||
// static
|
||||
void BackgroundChild::CloseForCurrentThread() {
|
||||
ChildImpl::CloseForCurrentThread();
|
||||
|
@ -671,6 +704,8 @@ bool ParentImpl::sShutdownHasStarted = false;
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
unsigned int ChildImpl::sThreadLocalIndex = kBadThreadLocalIndex;
|
||||
unsigned int ChildImpl::sThreadLocalIndexForSocketProcess =
|
||||
kBadThreadLocalIndex;
|
||||
|
||||
bool ChildImpl::sShutdownHasStarted = false;
|
||||
|
||||
|
@ -776,7 +811,7 @@ bool ParentImpl::GetLiveActorArray(
|
|||
// static
|
||||
bool ParentImpl::Alloc(ContentParent* aContent,
|
||||
Endpoint<PBackgroundParent>&& aEndpoint) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aEndpoint.IsValid());
|
||||
|
||||
|
@ -867,7 +902,7 @@ already_AddRefed<ChildImpl> ParentImpl::CreateActorForSameProcess(
|
|||
|
||||
// static
|
||||
bool ParentImpl::CreateBackgroundThread() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(!sBackgroundThread);
|
||||
MOZ_ASSERT(!sLiveActorsForBackgroundThread);
|
||||
|
@ -931,7 +966,7 @@ bool ParentImpl::CreateBackgroundThread() {
|
|||
|
||||
// static
|
||||
void ParentImpl::ShutdownBackgroundThread() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(sShutdownHasStarted);
|
||||
MOZ_ASSERT_IF(!sBackgroundThread, !sLiveActorCount);
|
||||
|
@ -976,7 +1011,7 @@ void ParentImpl::ShutdownBackgroundThread() {
|
|||
|
||||
// static
|
||||
void ParentImpl::ShutdownTimerCallback(nsITimer* aTimer, void* aClosure) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(sShutdownHasStarted);
|
||||
MOZ_ASSERT(sLiveActorCount);
|
||||
|
@ -997,7 +1032,7 @@ void ParentImpl::ShutdownTimerCallback(nsITimer* aTimer, void* aClosure) {
|
|||
void ParentImpl::Destroy() {
|
||||
// May be called on any thread!
|
||||
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(
|
||||
NewNonOwningRunnableMethod("ParentImpl::MainThreadActorDestroy", this,
|
||||
|
@ -1005,9 +1040,9 @@ void ParentImpl::Destroy() {
|
|||
}
|
||||
|
||||
void ParentImpl::MainThreadActorDestroy() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT_IF(mIsOtherProcessActor, mContent);
|
||||
MOZ_ASSERT_IF(mIsOtherProcessActor && XRE_IsParentProcess(), mContent);
|
||||
MOZ_ASSERT_IF(!mIsOtherProcessActor, !mContent);
|
||||
|
||||
mContent = nullptr;
|
||||
|
@ -1020,7 +1055,7 @@ void ParentImpl::MainThreadActorDestroy() {
|
|||
}
|
||||
|
||||
void ParentImpl::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(!mActorDestroyed);
|
||||
MOZ_ASSERT_IF(mIsOtherProcessActor, mLiveActorArray);
|
||||
|
@ -1051,7 +1086,7 @@ NS_IMPL_ISUPPORTS(ParentImpl::ShutdownObserver, nsIObserver)
|
|||
NS_IMETHODIMP
|
||||
ParentImpl::ShutdownObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(!sShutdownHasStarted);
|
||||
MOZ_ASSERT(!strcmp(aTopic, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID));
|
||||
|
@ -1060,7 +1095,11 @@ ParentImpl::ShutdownObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
// Do this first before calling (and spinning the event loop in)
|
||||
// ShutdownBackgroundThread().
|
||||
ChildImpl::Shutdown();
|
||||
// Since we didn't call BackgroundChild::Startup() in socket process,
|
||||
// we can't call ChildImpl::Shutdown() here.
|
||||
if (!XRE_IsSocketProcess()) {
|
||||
ChildImpl::Shutdown();
|
||||
}
|
||||
|
||||
ShutdownBackgroundThread();
|
||||
|
||||
|
@ -1069,7 +1108,7 @@ ParentImpl::ShutdownObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
NS_IMETHODIMP
|
||||
ParentImpl::RequestMessageLoopRunnable::Run() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
MOZ_ASSERT(mTargetThread);
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
|
@ -1115,7 +1154,7 @@ ParentImpl::RequestMessageLoopRunnable::Run() {
|
|||
|
||||
NS_IMETHODIMP
|
||||
ParentImpl::ShutdownBackgroundThreadRunnable::Run() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
|
||||
// It is possible that another background thread was created while this thread
|
||||
// was shutting down. In that case we can't assert anything about
|
||||
|
@ -1127,7 +1166,7 @@ ParentImpl::ShutdownBackgroundThreadRunnable::Run() {
|
|||
|
||||
NS_IMETHODIMP
|
||||
ParentImpl::ForceCloseBackgroundActorsRunnable::Run() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
MOZ_ASSERT(mActorArray);
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
|
@ -1154,7 +1193,7 @@ ParentImpl::ForceCloseBackgroundActorsRunnable::Run() {
|
|||
|
||||
NS_IMETHODIMP
|
||||
ParentImpl::ConnectActorRunnable::Run() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
// Transfer ownership to this thread. If Open() fails then we will release
|
||||
|
@ -1246,12 +1285,19 @@ void ChildImpl::Startup() {
|
|||
|
||||
MOZ_ASSERT(sThreadLocalIndex == kBadThreadLocalIndex,
|
||||
"BackgroundChild::Startup() called more than once!");
|
||||
MOZ_ASSERT(sThreadLocalIndexForSocketProcess == kBadThreadLocalIndex,
|
||||
"BackgroundChild::Startup() called more than once!");
|
||||
|
||||
PRStatus status =
|
||||
PR_NewThreadPrivateIndex(&sThreadLocalIndex, ThreadLocalDestructor);
|
||||
MOZ_RELEASE_ASSERT(status == PR_SUCCESS, "PR_NewThreadPrivateIndex failed!");
|
||||
|
||||
status = PR_NewThreadPrivateIndex(&sThreadLocalIndexForSocketProcess,
|
||||
ThreadLocalDestructor);
|
||||
MOZ_RELEASE_ASSERT(status == PR_SUCCESS, "PR_NewThreadPrivateIndex failed!");
|
||||
|
||||
MOZ_ASSERT(sThreadLocalIndex != kBadThreadLocalIndex);
|
||||
MOZ_ASSERT(sThreadLocalIndexForSocketProcess != kBadThreadLocalIndex);
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
|
||||
MOZ_RELEASE_ASSERT(observerService);
|
||||
|
@ -1263,27 +1309,18 @@ void ChildImpl::Startup() {
|
|||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
|
||||
// static
|
||||
void ChildImpl::Shutdown() {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (sShutdownHasStarted) {
|
||||
MOZ_ASSERT_IF(sThreadLocalIndex != kBadThreadLocalIndex,
|
||||
!PR_GetThreadPrivate(sThreadLocalIndex));
|
||||
return;
|
||||
}
|
||||
|
||||
sShutdownHasStarted = true;
|
||||
|
||||
MOZ_ASSERT(sThreadLocalIndex != kBadThreadLocalIndex);
|
||||
void ChildImpl::ShutdownWithThreadLocalIndex(unsigned int aThreadLocalIndex) {
|
||||
MOZ_ASSERT(aThreadLocalIndex != kBadThreadLocalIndex);
|
||||
|
||||
ThreadLocalInfo* threadLocalInfo;
|
||||
#ifdef DEBUG
|
||||
threadLocalInfo =
|
||||
static_cast<ThreadLocalInfo*>(PR_GetThreadPrivate(sThreadLocalIndex));
|
||||
static_cast<ThreadLocalInfo*>(PR_GetThreadPrivate(aThreadLocalIndex));
|
||||
MOZ_ASSERT(!threadLocalInfo);
|
||||
#endif
|
||||
threadLocalInfo = sMainThreadInfo;
|
||||
threadLocalInfo = aThreadLocalIndex == sThreadLocalIndex
|
||||
? sMainThreadInfo
|
||||
: sMainThreadInfoForSocketProcess;
|
||||
|
||||
if (threadLocalInfo) {
|
||||
#ifdef DEBUG
|
||||
|
@ -1292,11 +1329,38 @@ void ChildImpl::Shutdown() {
|
|||
#endif
|
||||
|
||||
ThreadLocalDestructor(threadLocalInfo);
|
||||
sMainThreadInfo = nullptr;
|
||||
if (aThreadLocalIndex == sThreadLocalIndex) {
|
||||
sMainThreadInfo = nullptr;
|
||||
} else {
|
||||
sMainThreadInfoForSocketProcess = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void ChildImpl::Shutdown() {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (sShutdownHasStarted) {
|
||||
MOZ_ASSERT_IF(sThreadLocalIndex != kBadThreadLocalIndex,
|
||||
!PR_GetThreadPrivate(sThreadLocalIndex));
|
||||
MOZ_ASSERT_IF(sThreadLocalIndexForSocketProcess != kBadThreadLocalIndex,
|
||||
!PR_GetThreadPrivate(sThreadLocalIndexForSocketProcess));
|
||||
return;
|
||||
}
|
||||
|
||||
sShutdownHasStarted = true;
|
||||
|
||||
ShutdownWithThreadLocalIndex(sThreadLocalIndex);
|
||||
|
||||
if (sThreadLocalIndexForSocketProcess != kBadThreadLocalIndex) {
|
||||
ShutdownWithThreadLocalIndex(sThreadLocalIndexForSocketProcess);
|
||||
}
|
||||
}
|
||||
|
||||
ChildImpl::ThreadLocalInfo* ChildImpl::sMainThreadInfo = nullptr;
|
||||
ChildImpl::ThreadLocalInfo* ChildImpl::sMainThreadInfoForSocketProcess =
|
||||
nullptr;
|
||||
|
||||
// static
|
||||
PBackgroundChild* ChildImpl::GetForCurrentThread() {
|
||||
|
@ -1314,6 +1378,41 @@ PBackgroundChild* ChildImpl::GetForCurrentThread() {
|
|||
return threadLocalInfo->mActor;
|
||||
}
|
||||
|
||||
/* static */
|
||||
PBackgroundChild* ChildImpl::GetFromThreadInfo(
|
||||
nsIEventTarget* aMainEventTarget, ThreadLocalInfo* aThreadLocalInfo) {
|
||||
MOZ_ASSERT(aThreadLocalInfo);
|
||||
|
||||
if (aThreadLocalInfo->mActor) {
|
||||
RefPtr<SendInitBackgroundRunnable>& runnable =
|
||||
aThreadLocalInfo->mSendInitBackgroundRunnable;
|
||||
|
||||
if (aMainEventTarget && runnable) {
|
||||
// The SendInitBackgroundRunnable was already dispatched to the main
|
||||
// thread to finish initialization of a new background child actor.
|
||||
// However, the caller passed a custom main event target which indicates
|
||||
// that synchronous blocking of the main thread is happening (done by
|
||||
// creating a nested event target and spinning the event loop).
|
||||
// It can happen that the SendInitBackgroundRunnable didn't have a chance
|
||||
// to run before the synchronous blocking has occured. Unblocking of the
|
||||
// main thread can depend on an IPC message received on this thread, so
|
||||
// we have to dispatch the SendInitBackgroundRunnable to the custom main
|
||||
// event target too, otherwise IPC will be only queueing messages on this
|
||||
// thread. The runnable will run twice in the end, but that's a harmless
|
||||
// race between the main and nested event queue of the main thread.
|
||||
// There's a guard in the runnable implementation for calling
|
||||
// SendInitBackground only once.
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
aMainEventTarget->Dispatch(runnable, NS_DISPATCH_NORMAL));
|
||||
}
|
||||
|
||||
return aThreadLocalInfo->mActor;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* static */
|
||||
PBackgroundChild* ChildImpl::GetOrCreateForCurrentThread(
|
||||
nsIEventTarget* aMainEventTarget) {
|
||||
|
@ -1346,31 +1445,10 @@ PBackgroundChild* ChildImpl::GetOrCreateForCurrentThread(
|
|||
threadLocalInfo = newInfo.forget();
|
||||
}
|
||||
|
||||
if (threadLocalInfo->mActor) {
|
||||
RefPtr<SendInitBackgroundRunnable>& runnable =
|
||||
threadLocalInfo->mSendInitBackgroundRunnable;
|
||||
|
||||
if (aMainEventTarget && runnable) {
|
||||
// The SendInitBackgroundRunnable was already dispatched to the main
|
||||
// thread to finish initialization of a new background child actor.
|
||||
// However, the caller passed a custom main event target which indicates
|
||||
// that synchronous blocking of the main thread is happening (done by
|
||||
// creating a nested event target and spinning the event loop).
|
||||
// It can happen that the SendInitBackgroundRunnable didn't have a chance
|
||||
// to run before the synchronous blocking has occured. Unblocking of the
|
||||
// main thread can depend on an IPC message received on this thread, so
|
||||
// we have to dispatch the SendInitBackgroundRunnable to the custom main
|
||||
// event target too, otherwise IPC will be only queueing messages on this
|
||||
// thread. The runnable will run twice in the end, but that's a harmless
|
||||
// race between the main and nested event queue of the main thread.
|
||||
// There's a guard in the runnable implementation for calling
|
||||
// SendInitBackground only once.
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
aMainEventTarget->Dispatch(runnable, NS_DISPATCH_NORMAL));
|
||||
}
|
||||
|
||||
return threadLocalInfo->mActor;
|
||||
PBackgroundChild* bgChild =
|
||||
GetFromThreadInfo(aMainEventTarget, threadLocalInfo);
|
||||
if (bgChild) {
|
||||
return bgChild;
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
|
@ -1407,7 +1485,15 @@ PBackgroundChild* ChildImpl::GetOrCreateForCurrentThread(
|
|||
|
||||
RefPtr<SendInitBackgroundRunnable> runnable;
|
||||
if (!NS_IsMainThread()) {
|
||||
runnable = SendInitBackgroundRunnable::Create(std::move(parent));
|
||||
runnable = SendInitBackgroundRunnable::Create(
|
||||
std::move(parent), [](Endpoint<PBackgroundParent>&& aParent) {
|
||||
RefPtr<ContentChild> content = ContentChild::GetSingleton();
|
||||
MOZ_ASSERT(content);
|
||||
|
||||
if (!content->SendInitBackground(std::move(aParent))) {
|
||||
MOZ_CRASH("Failed to create top level actor!");
|
||||
}
|
||||
});
|
||||
if (!runnable) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1445,18 +1531,116 @@ PBackgroundChild* ChildImpl::GetOrCreateForCurrentThread(
|
|||
return actor;
|
||||
}
|
||||
|
||||
// static
|
||||
void ChildImpl::CloseForCurrentThread() {
|
||||
MOZ_ASSERT(!NS_IsMainThread(),
|
||||
"PBackground for the main thread should be shut down via "
|
||||
"ChildImpl::Shutdown().");
|
||||
/* static */
|
||||
PBackgroundChild* ChildImpl::GetOrCreateSocketActorForCurrentThread(
|
||||
nsIEventTarget* aMainEventTarget) {
|
||||
MOZ_ASSERT_IF(NS_IsMainThread(), !aMainEventTarget);
|
||||
|
||||
if (sThreadLocalIndex == kBadThreadLocalIndex) {
|
||||
return;
|
||||
MOZ_ASSERT(sThreadLocalIndexForSocketProcess != kBadThreadLocalIndex,
|
||||
"BackgroundChild::Startup() was never called!");
|
||||
|
||||
if (NS_IsMainThread() && sShutdownHasStarted) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto threadLocalInfo =
|
||||
static_cast<ThreadLocalInfo*>(PR_GetThreadPrivate(sThreadLocalIndex));
|
||||
NS_IsMainThread() ? sMainThreadInfoForSocketProcess
|
||||
: static_cast<ThreadLocalInfo*>(PR_GetThreadPrivate(
|
||||
sThreadLocalIndexForSocketProcess));
|
||||
|
||||
if (!threadLocalInfo) {
|
||||
nsAutoPtr<ThreadLocalInfo> newInfo(new ThreadLocalInfo());
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
sMainThreadInfoForSocketProcess = newInfo;
|
||||
} else {
|
||||
if (PR_SetThreadPrivate(sThreadLocalIndexForSocketProcess, newInfo) !=
|
||||
PR_SUCCESS) {
|
||||
CRASH_IN_CHILD_PROCESS("PR_SetThreadPrivate failed!");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
threadLocalInfo = newInfo.forget();
|
||||
}
|
||||
|
||||
PBackgroundChild* bgChild =
|
||||
GetFromThreadInfo(aMainEventTarget, threadLocalInfo);
|
||||
if (bgChild) {
|
||||
return bgChild;
|
||||
}
|
||||
|
||||
RefPtr<SocketProcessBridgeChild> bridgeChild =
|
||||
SocketProcessBridgeChild::GetSingleton();
|
||||
|
||||
if (!bridgeChild || bridgeChild->IsShuttingDown()) {
|
||||
// The transport for SocketProcessBridgeChild is shut down
|
||||
// and can't be used to open PBackground.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Endpoint<PBackgroundParent> parent;
|
||||
Endpoint<PBackgroundChild> child;
|
||||
nsresult rv;
|
||||
rv = PBackground::CreateEndpoints(bridgeChild->SocketProcessPid(),
|
||||
base::GetCurrentProcId(), &parent, &child);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to create top level actor!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<SendInitBackgroundRunnable> runnable;
|
||||
if (!NS_IsMainThread()) {
|
||||
runnable = SendInitBackgroundRunnable::Create(
|
||||
std::move(parent), [](Endpoint<PBackgroundParent>&& aParent) {
|
||||
RefPtr<SocketProcessBridgeChild> bridgeChild =
|
||||
SocketProcessBridgeChild::GetSingleton();
|
||||
|
||||
if (!bridgeChild->SendInitBackground(std::move(aParent))) {
|
||||
MOZ_CRASH("Failed to create top level actor!");
|
||||
}
|
||||
});
|
||||
if (!runnable) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<ChildImpl> strongActor = new ChildImpl();
|
||||
|
||||
if (!child.Bind(strongActor)) {
|
||||
CRASH_IN_CHILD_PROCESS("Failed to bind ChildImpl!");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
strongActor->SetActorAlive();
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
if (!bridgeChild->SendInitBackground(std::move(parent))) {
|
||||
NS_WARNING("Failed to create top level actor!");
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
if (aMainEventTarget) {
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
aMainEventTarget->Dispatch(runnable, NS_DISPATCH_NORMAL));
|
||||
} else {
|
||||
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable));
|
||||
}
|
||||
|
||||
threadLocalInfo->mSendInitBackgroundRunnable = runnable;
|
||||
}
|
||||
|
||||
RefPtr<ChildImpl>& actor = threadLocalInfo->mActor;
|
||||
strongActor.swap(actor);
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
// static
|
||||
void ChildImpl::CloseThreadWithIndex(unsigned int aThreadLocalIndex) {
|
||||
auto threadLocalInfo =
|
||||
static_cast<ThreadLocalInfo*>(PR_GetThreadPrivate(aThreadLocalIndex));
|
||||
|
||||
if (!threadLocalInfo) {
|
||||
return;
|
||||
|
@ -1468,10 +1652,24 @@ void ChildImpl::CloseForCurrentThread() {
|
|||
#endif
|
||||
|
||||
// Clearing the thread local will synchronously close the actor.
|
||||
DebugOnly<PRStatus> status = PR_SetThreadPrivate(sThreadLocalIndex, nullptr);
|
||||
DebugOnly<PRStatus> status = PR_SetThreadPrivate(aThreadLocalIndex, nullptr);
|
||||
MOZ_ASSERT(status == PR_SUCCESS);
|
||||
}
|
||||
|
||||
// static
|
||||
void ChildImpl::CloseForCurrentThread() {
|
||||
MOZ_ASSERT(!NS_IsMainThread(),
|
||||
"PBackground for the main thread should be shut down via "
|
||||
"ChildImpl::Shutdown().");
|
||||
|
||||
if (sThreadLocalIndex != kBadThreadLocalIndex) {
|
||||
CloseThreadWithIndex(sThreadLocalIndex);
|
||||
}
|
||||
if (sThreadLocalIndexForSocketProcess != kBadThreadLocalIndex) {
|
||||
CloseThreadWithIndex(sThreadLocalIndexForSocketProcess);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
BackgroundChildImpl::ThreadLocal* ChildImpl::GetThreadLocalForCurrentThread() {
|
||||
MOZ_ASSERT(sThreadLocalIndex != kBadThreadLocalIndex,
|
||||
|
@ -1541,11 +1739,12 @@ ChildImpl::ShutdownObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
// static
|
||||
already_AddRefed<ChildImpl::SendInitBackgroundRunnable>
|
||||
ChildImpl::SendInitBackgroundRunnable::Create(
|
||||
Endpoint<PBackgroundParent>&& aParent) {
|
||||
Endpoint<PBackgroundParent>&& aParent,
|
||||
std::function<void(Endpoint<PBackgroundParent>&& aParent)>&& aFunc) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
RefPtr<SendInitBackgroundRunnable> runnable =
|
||||
new SendInitBackgroundRunnable(std::move(aParent));
|
||||
new SendInitBackgroundRunnable(std::move(aParent), std::move(aFunc));
|
||||
|
||||
WorkerPrivate* workerPrivate = mozilla::dom::GetCurrentThreadWorkerPrivate();
|
||||
if (!workerPrivate) {
|
||||
|
@ -1572,12 +1771,7 @@ ChildImpl::SendInitBackgroundRunnable::Run() {
|
|||
|
||||
mSentInitBackground = true;
|
||||
|
||||
RefPtr<ContentChild> content = ContentChild::GetSingleton();
|
||||
MOZ_ASSERT(content);
|
||||
|
||||
if (!content->SendInitBackground(std::move(mParent))) {
|
||||
MOZ_CRASH("Failed to create top level actor!");
|
||||
}
|
||||
mSendInitfunc(std::move(mParent));
|
||||
|
||||
nsCOMPtr<nsISerialEventTarget> owningEventTarget;
|
||||
{
|
||||
|
|
|
@ -15,6 +15,13 @@ template <class>
|
|||
struct already_AddRefed;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace net {
|
||||
|
||||
class SocketProcessBridgeParent;
|
||||
|
||||
} // namespace net
|
||||
|
||||
namespace dom {
|
||||
|
||||
class BlobImpl;
|
||||
|
@ -38,6 +45,7 @@ class BackgroundParent final {
|
|||
typedef mozilla::dom::BlobImpl BlobImpl;
|
||||
typedef mozilla::dom::ContentParent ContentParent;
|
||||
typedef mozilla::ipc::Transport Transport;
|
||||
friend class mozilla::net::SocketProcessBridgeParent;
|
||||
|
||||
public:
|
||||
// This function allows the caller to determine if the given parent actor
|
||||
|
@ -73,6 +81,9 @@ class BackgroundParent final {
|
|||
// Only called by ContentParent for cross-process actors.
|
||||
static bool Alloc(ContentParent* aContent,
|
||||
Endpoint<PBackgroundParent>&& aEndpoint);
|
||||
|
||||
// Only called by SocketProcessBridgeParent for cross-process actors.
|
||||
static bool Alloc(Endpoint<PBackgroundParent>&& aEndpoint);
|
||||
};
|
||||
|
||||
// Implemented in BackgroundImpl.cpp.
|
||||
|
@ -91,6 +102,10 @@ inline void AssertIsOnBackgroundThread() {}
|
|||
|
||||
inline void AssertIsInMainProcess() { MOZ_ASSERT(XRE_IsParentProcess()); }
|
||||
|
||||
inline void AssertIsInMainOrSocketProcess() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsSocketProcess());
|
||||
}
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -118,27 +118,27 @@ using mozilla::dom::ContentParent;
|
|||
using mozilla::dom::ServiceWorkerRegistrationData;
|
||||
|
||||
BackgroundParentImpl::BackgroundParentImpl() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
|
||||
MOZ_COUNT_CTOR(mozilla::ipc::BackgroundParentImpl);
|
||||
}
|
||||
|
||||
BackgroundParentImpl::~BackgroundParentImpl() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnMainThread();
|
||||
|
||||
MOZ_COUNT_DTOR(mozilla::ipc::BackgroundParentImpl);
|
||||
}
|
||||
|
||||
void BackgroundParentImpl::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
}
|
||||
|
||||
BackgroundParentImpl::PBackgroundTestParent*
|
||||
BackgroundParentImpl::AllocPBackgroundTestParent(const nsCString& aTestArg) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return new TestParent();
|
||||
|
@ -146,7 +146,7 @@ BackgroundParentImpl::AllocPBackgroundTestParent(const nsCString& aTestArg) {
|
|||
|
||||
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBackgroundTestConstructor(
|
||||
PBackgroundTestParent* aActor, const nsCString& aTestArg) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -158,7 +158,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBackgroundTestConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBackgroundTestParent(
|
||||
PBackgroundTestParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -170,7 +170,7 @@ auto BackgroundParentImpl::AllocPBackgroundIDBFactoryParent(
|
|||
const LoggingInfo& aLoggingInfo) -> PBackgroundIDBFactoryParent* {
|
||||
using mozilla::dom::indexedDB::AllocPBackgroundIDBFactoryParent;
|
||||
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return AllocPBackgroundIDBFactoryParent(aLoggingInfo);
|
||||
|
@ -181,7 +181,7 @@ BackgroundParentImpl::RecvPBackgroundIDBFactoryConstructor(
|
|||
PBackgroundIDBFactoryParent* aActor, const LoggingInfo& aLoggingInfo) {
|
||||
using mozilla::dom::indexedDB::RecvPBackgroundIDBFactoryConstructor;
|
||||
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -195,7 +195,7 @@ bool BackgroundParentImpl::DeallocPBackgroundIDBFactoryParent(
|
|||
PBackgroundIDBFactoryParent* aActor) {
|
||||
using mozilla::dom::indexedDB::DeallocPBackgroundIDBFactoryParent;
|
||||
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -204,7 +204,7 @@ bool BackgroundParentImpl::DeallocPBackgroundIDBFactoryParent(
|
|||
|
||||
auto BackgroundParentImpl::AllocPBackgroundIndexedDBUtilsParent()
|
||||
-> PBackgroundIndexedDBUtilsParent* {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return mozilla::dom::indexedDB::AllocPBackgroundIndexedDBUtilsParent();
|
||||
|
@ -212,7 +212,7 @@ auto BackgroundParentImpl::AllocPBackgroundIndexedDBUtilsParent()
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBackgroundIndexedDBUtilsParent(
|
||||
PBackgroundIndexedDBUtilsParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -221,7 +221,7 @@ bool BackgroundParentImpl::DeallocPBackgroundIndexedDBUtilsParent(
|
|||
}
|
||||
|
||||
mozilla::ipc::IPCResult BackgroundParentImpl::RecvFlushPendingFileDeletions() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
if (!mozilla::dom::indexedDB::RecvFlushPendingFileDeletions()) {
|
||||
|
@ -233,7 +233,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvFlushPendingFileDeletions() {
|
|||
BackgroundParentImpl::PBackgroundSDBConnectionParent*
|
||||
BackgroundParentImpl::AllocPBackgroundSDBConnectionParent(
|
||||
const PrincipalInfo& aPrincipalInfo) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return mozilla::dom::AllocPBackgroundSDBConnectionParent(aPrincipalInfo);
|
||||
|
@ -243,7 +243,7 @@ mozilla::ipc::IPCResult
|
|||
BackgroundParentImpl::RecvPBackgroundSDBConnectionConstructor(
|
||||
PBackgroundSDBConnectionParent* aActor,
|
||||
const PrincipalInfo& aPrincipalInfo) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -256,7 +256,7 @@ BackgroundParentImpl::RecvPBackgroundSDBConnectionConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBackgroundSDBConnectionParent(
|
||||
PBackgroundSDBConnectionParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -267,7 +267,7 @@ BackgroundParentImpl::PBackgroundLSDatabaseParent*
|
|||
BackgroundParentImpl::AllocPBackgroundLSDatabaseParent(
|
||||
const PrincipalInfo& aPrincipalInfo, const uint32_t& aPrivateBrowsingId,
|
||||
const uint64_t& aDatastoreId) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return mozilla::dom::AllocPBackgroundLSDatabaseParent(
|
||||
|
@ -278,7 +278,7 @@ mozilla::ipc::IPCResult
|
|||
BackgroundParentImpl::RecvPBackgroundLSDatabaseConstructor(
|
||||
PBackgroundLSDatabaseParent* aActor, const PrincipalInfo& aPrincipalInfo,
|
||||
const uint32_t& aPrivateBrowsingId, const uint64_t& aDatastoreId) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -291,7 +291,7 @@ BackgroundParentImpl::RecvPBackgroundLSDatabaseConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBackgroundLSDatabaseParent(
|
||||
PBackgroundLSDatabaseParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -301,7 +301,7 @@ bool BackgroundParentImpl::DeallocPBackgroundLSDatabaseParent(
|
|||
BackgroundParentImpl::PBackgroundLSObserverParent*
|
||||
BackgroundParentImpl::AllocPBackgroundLSObserverParent(
|
||||
const uint64_t& aObserverId) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return mozilla::dom::AllocPBackgroundLSObserverParent(aObserverId);
|
||||
|
@ -310,7 +310,7 @@ BackgroundParentImpl::AllocPBackgroundLSObserverParent(
|
|||
mozilla::ipc::IPCResult
|
||||
BackgroundParentImpl::RecvPBackgroundLSObserverConstructor(
|
||||
PBackgroundLSObserverParent* aActor, const uint64_t& aObserverId) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -323,7 +323,7 @@ BackgroundParentImpl::RecvPBackgroundLSObserverConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBackgroundLSObserverParent(
|
||||
PBackgroundLSObserverParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -333,7 +333,7 @@ bool BackgroundParentImpl::DeallocPBackgroundLSObserverParent(
|
|||
BackgroundParentImpl::PBackgroundLSRequestParent*
|
||||
BackgroundParentImpl::AllocPBackgroundLSRequestParent(
|
||||
const LSRequestParams& aParams) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return mozilla::dom::AllocPBackgroundLSRequestParent(this, aParams);
|
||||
|
@ -342,7 +342,7 @@ BackgroundParentImpl::AllocPBackgroundLSRequestParent(
|
|||
mozilla::ipc::IPCResult
|
||||
BackgroundParentImpl::RecvPBackgroundLSRequestConstructor(
|
||||
PBackgroundLSRequestParent* aActor, const LSRequestParams& aParams) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -354,7 +354,7 @@ BackgroundParentImpl::RecvPBackgroundLSRequestConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBackgroundLSRequestParent(
|
||||
PBackgroundLSRequestParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -364,7 +364,7 @@ bool BackgroundParentImpl::DeallocPBackgroundLSRequestParent(
|
|||
BackgroundParentImpl::PBackgroundLSSimpleRequestParent*
|
||||
BackgroundParentImpl::AllocPBackgroundLSSimpleRequestParent(
|
||||
const LSSimpleRequestParams& aParams) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return mozilla::dom::AllocPBackgroundLSSimpleRequestParent(aParams);
|
||||
|
@ -374,7 +374,7 @@ mozilla::ipc::IPCResult
|
|||
BackgroundParentImpl::RecvPBackgroundLSSimpleRequestConstructor(
|
||||
PBackgroundLSSimpleRequestParent* aActor,
|
||||
const LSSimpleRequestParams& aParams) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -387,7 +387,7 @@ BackgroundParentImpl::RecvPBackgroundLSSimpleRequestConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBackgroundLSSimpleRequestParent(
|
||||
PBackgroundLSSimpleRequestParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -398,7 +398,7 @@ BackgroundParentImpl::PBackgroundLocalStorageCacheParent*
|
|||
BackgroundParentImpl::AllocPBackgroundLocalStorageCacheParent(
|
||||
const PrincipalInfo& aPrincipalInfo, const nsCString& aOriginKey,
|
||||
const uint32_t& aPrivateBrowsingId) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return mozilla::dom::AllocPBackgroundLocalStorageCacheParent(
|
||||
|
@ -410,7 +410,7 @@ BackgroundParentImpl::RecvPBackgroundLocalStorageCacheConstructor(
|
|||
PBackgroundLocalStorageCacheParent* aActor,
|
||||
const PrincipalInfo& aPrincipalInfo, const nsCString& aOriginKey,
|
||||
const uint32_t& aPrivateBrowsingId) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -420,7 +420,7 @@ BackgroundParentImpl::RecvPBackgroundLocalStorageCacheConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBackgroundLocalStorageCacheParent(
|
||||
PBackgroundLocalStorageCacheParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -429,7 +429,7 @@ bool BackgroundParentImpl::DeallocPBackgroundLocalStorageCacheParent(
|
|||
|
||||
auto BackgroundParentImpl::AllocPBackgroundStorageParent(
|
||||
const nsString& aProfilePath) -> PBackgroundStorageParent* {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return mozilla::dom::AllocPBackgroundStorageParent(aProfilePath);
|
||||
|
@ -437,7 +437,7 @@ auto BackgroundParentImpl::AllocPBackgroundStorageParent(
|
|||
|
||||
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBackgroundStorageConstructor(
|
||||
PBackgroundStorageParent* aActor, const nsString& aProfilePath) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -446,7 +446,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBackgroundStorageConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBackgroundStorageParent(
|
||||
PBackgroundStorageParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -460,7 +460,7 @@ PPendingIPCBlobParent* BackgroundParentImpl::AllocPPendingIPCBlobParent(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPPendingIPCBlobParent(
|
||||
PPendingIPCBlobParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -545,7 +545,7 @@ bool BackgroundParentImpl::DeallocPTemporaryIPCBlobParent(
|
|||
|
||||
PIPCBlobInputStreamParent* BackgroundParentImpl::AllocPIPCBlobInputStreamParent(
|
||||
const nsID& aID, const uint64_t& aSize) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<mozilla::dom::IPCBlobInputStreamParent> actor =
|
||||
|
@ -566,7 +566,7 @@ BackgroundParentImpl::RecvPIPCBlobInputStreamConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPIPCBlobInputStreamParent(
|
||||
PIPCBlobInputStreamParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -577,7 +577,7 @@ bool BackgroundParentImpl::DeallocPIPCBlobInputStreamParent(
|
|||
|
||||
PFileDescriptorSetParent* BackgroundParentImpl::AllocPFileDescriptorSetParent(
|
||||
const FileDescriptor& aFileDescriptor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return new FileDescriptorSetParent(aFileDescriptor);
|
||||
|
@ -585,7 +585,7 @@ PFileDescriptorSetParent* BackgroundParentImpl::AllocPFileDescriptorSetParent(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPFileDescriptorSetParent(
|
||||
PFileDescriptorSetParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -617,7 +617,7 @@ bool BackgroundParentImpl::DeallocPParentToChildStreamParent(
|
|||
}
|
||||
|
||||
BackgroundParentImpl::PVsyncParent* BackgroundParentImpl::AllocPVsyncParent() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<mozilla::layout::VsyncParent> actor =
|
||||
|
@ -628,7 +628,7 @@ BackgroundParentImpl::PVsyncParent* BackgroundParentImpl::AllocPVsyncParent() {
|
|||
}
|
||||
|
||||
bool BackgroundParentImpl::DeallocPVsyncParent(PVsyncParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -639,7 +639,7 @@ bool BackgroundParentImpl::DeallocPVsyncParent(PVsyncParent* aActor) {
|
|||
}
|
||||
|
||||
camera::PCamerasParent* BackgroundParentImpl::AllocPCamerasParent() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
#ifdef MOZ_WEBRTC
|
||||
|
@ -653,7 +653,7 @@ camera::PCamerasParent* BackgroundParentImpl::AllocPCamerasParent() {
|
|||
|
||||
bool BackgroundParentImpl::DeallocPCamerasParent(
|
||||
camera::PCamerasParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -675,7 +675,7 @@ auto BackgroundParentImpl::AllocPUDPSocketParent(
|
|||
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPUDPSocketConstructor(
|
||||
PUDPSocketParent* aActor, const OptionalPrincipalInfo& aOptionalPrincipal,
|
||||
const nsCString& aFilter) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
if (aOptionalPrincipal.type() == OptionalPrincipalInfo::TPrincipalInfo) {
|
||||
|
@ -713,7 +713,7 @@ mozilla::dom::PBroadcastChannelParent*
|
|||
BackgroundParentImpl::AllocPBroadcastChannelParent(
|
||||
const PrincipalInfo& aPrincipalInfo, const nsCString& aOrigin,
|
||||
const nsString& aChannel) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
nsString originChannelKey;
|
||||
|
@ -750,7 +750,7 @@ class CheckPrincipalRunnable final : public Runnable {
|
|||
mContentParent(aParent),
|
||||
mPrincipalInfo(aPrincipalInfo),
|
||||
mOrigin(aOrigin) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
MOZ_ASSERT(mContentParent);
|
||||
|
@ -791,7 +791,7 @@ class CheckPrincipalRunnable final : public Runnable {
|
|||
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBroadcastChannelConstructor(
|
||||
PBroadcastChannelParent* actor, const PrincipalInfo& aPrincipalInfo,
|
||||
const nsCString& aOrigin, const nsString& aChannel) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<ContentParent> parent = BackgroundParent::GetContentParent(this);
|
||||
|
@ -810,7 +810,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPBroadcastChannelConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPBroadcastChannelParent(
|
||||
PBroadcastChannelParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -820,7 +820,7 @@ bool BackgroundParentImpl::DeallocPBroadcastChannelParent(
|
|||
|
||||
mozilla::dom::PServiceWorkerManagerParent*
|
||||
BackgroundParentImpl::AllocPServiceWorkerManagerParent() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<dom::ServiceWorkerManagerParent> agent =
|
||||
|
@ -830,7 +830,7 @@ BackgroundParentImpl::AllocPServiceWorkerManagerParent() {
|
|||
|
||||
bool BackgroundParentImpl::DeallocPServiceWorkerManagerParent(
|
||||
PServiceWorkerManagerParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -842,7 +842,7 @@ bool BackgroundParentImpl::DeallocPServiceWorkerManagerParent(
|
|||
|
||||
mozilla::ipc::IPCResult
|
||||
BackgroundParentImpl::RecvShutdownServiceWorkerRegistrar() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
if (BackgroundParent::IsOtherProcessActor(this)) {
|
||||
|
@ -894,7 +894,7 @@ bool BackgroundParentImpl::DeallocPCacheStreamControlParent(
|
|||
PMessagePortParent* BackgroundParentImpl::AllocPMessagePortParent(
|
||||
const nsID& aUUID, const nsID& aDestinationUUID,
|
||||
const uint32_t& aSequenceID) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return new MessagePortParent(aUUID);
|
||||
|
@ -903,7 +903,7 @@ PMessagePortParent* BackgroundParentImpl::AllocPMessagePortParent(
|
|||
mozilla::ipc::IPCResult BackgroundParentImpl::RecvPMessagePortConstructor(
|
||||
PMessagePortParent* aActor, const nsID& aUUID, const nsID& aDestinationUUID,
|
||||
const uint32_t& aSequenceID) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
MessagePortParent* mp = static_cast<MessagePortParent*>(aActor);
|
||||
|
@ -915,7 +915,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPMessagePortConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPMessagePortParent(
|
||||
PMessagePortParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -926,7 +926,7 @@ bool BackgroundParentImpl::DeallocPMessagePortParent(
|
|||
mozilla::ipc::IPCResult BackgroundParentImpl::RecvMessagePortForceClose(
|
||||
const nsID& aUUID, const nsID& aDestinationUUID,
|
||||
const uint32_t& aSequenceID) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
if (!MessagePortParent::ForceClose(aUUID, aDestinationUUID, aSequenceID)) {
|
||||
|
@ -939,7 +939,7 @@ PAsmJSCacheEntryParent* BackgroundParentImpl::AllocPAsmJSCacheEntryParent(
|
|||
const dom::asmjscache::OpenMode& aOpenMode,
|
||||
const dom::asmjscache::WriteParams& aWriteParams,
|
||||
const PrincipalInfo& aPrincipalInfo) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return dom::asmjscache::AllocEntryParent(aOpenMode, aWriteParams,
|
||||
|
@ -948,7 +948,7 @@ PAsmJSCacheEntryParent* BackgroundParentImpl::AllocPAsmJSCacheEntryParent(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPAsmJSCacheEntryParent(
|
||||
PAsmJSCacheEntryParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
dom::asmjscache::DeallocEntryParent(aActor);
|
||||
|
@ -956,14 +956,14 @@ bool BackgroundParentImpl::DeallocPAsmJSCacheEntryParent(
|
|||
}
|
||||
|
||||
BackgroundParentImpl::PQuotaParent* BackgroundParentImpl::AllocPQuotaParent() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
return mozilla::dom::quota::AllocPQuotaParent();
|
||||
}
|
||||
|
||||
bool BackgroundParentImpl::DeallocPQuotaParent(PQuotaParent* aActor) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
MOZ_ASSERT(aActor);
|
||||
|
||||
|
@ -973,7 +973,7 @@ bool BackgroundParentImpl::DeallocPQuotaParent(PQuotaParent* aActor) {
|
|||
dom::PFileSystemRequestParent*
|
||||
BackgroundParentImpl::AllocPFileSystemRequestParent(
|
||||
const FileSystemParams& aParams) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<FileSystemRequestParent> result = new FileSystemRequestParent();
|
||||
|
@ -993,7 +993,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPFileSystemRequestConstructor(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPFileSystemRequestParent(
|
||||
PFileSystemRequestParent* aDoomed) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<FileSystemRequestParent> parent =
|
||||
|
@ -1049,7 +1049,7 @@ bool BackgroundParentImpl::DeallocPWebAuthnTransactionParent(
|
|||
net::PHttpBackgroundChannelParent*
|
||||
BackgroundParentImpl::AllocPHttpBackgroundChannelParent(
|
||||
const uint64_t& aChannelId) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<net::HttpBackgroundChannelParent> actor =
|
||||
|
@ -1063,7 +1063,7 @@ mozilla::ipc::IPCResult
|
|||
BackgroundParentImpl::RecvPHttpBackgroundChannelConstructor(
|
||||
net::PHttpBackgroundChannelParent* aActor, const uint64_t& aChannelId) {
|
||||
MOZ_ASSERT(aActor);
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
net::HttpBackgroundChannelParent* aParent =
|
||||
|
@ -1079,7 +1079,7 @@ BackgroundParentImpl::RecvPHttpBackgroundChannelConstructor(
|
|||
bool BackgroundParentImpl::DeallocPHttpBackgroundChannelParent(
|
||||
net::PHttpBackgroundChannelParent* aActor) {
|
||||
MOZ_ASSERT(aActor);
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
// release extra refcount hold by AllocPHttpBackgroundChannelParent
|
||||
|
@ -1091,7 +1091,7 @@ bool BackgroundParentImpl::DeallocPHttpBackgroundChannelParent(
|
|||
|
||||
PMIDIPortParent* BackgroundParentImpl::AllocPMIDIPortParent(
|
||||
const MIDIPortInfo& aPortInfo, const bool& aSysexEnabled) {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<MIDIPortParent> result = new MIDIPortParent(aPortInfo, aSysexEnabled);
|
||||
|
@ -1100,7 +1100,7 @@ PMIDIPortParent* BackgroundParentImpl::AllocPMIDIPortParent(
|
|||
|
||||
bool BackgroundParentImpl::DeallocPMIDIPortParent(PMIDIPortParent* aActor) {
|
||||
MOZ_ASSERT(aActor);
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<MIDIPortParent> parent =
|
||||
|
@ -1110,7 +1110,7 @@ bool BackgroundParentImpl::DeallocPMIDIPortParent(PMIDIPortParent* aActor) {
|
|||
}
|
||||
|
||||
PMIDIManagerParent* BackgroundParentImpl::AllocPMIDIManagerParent() {
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<MIDIManagerParent> result = new MIDIManagerParent();
|
||||
|
@ -1121,7 +1121,7 @@ PMIDIManagerParent* BackgroundParentImpl::AllocPMIDIManagerParent() {
|
|||
bool BackgroundParentImpl::DeallocPMIDIManagerParent(
|
||||
PMIDIManagerParent* aActor) {
|
||||
MOZ_ASSERT(aActor);
|
||||
AssertIsInMainProcess();
|
||||
AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<MIDIManagerParent> parent =
|
||||
|
@ -1245,6 +1245,6 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvRemoveEndpoint(
|
|||
} // namespace mozilla
|
||||
|
||||
void TestParent::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
mozilla::ipc::AssertIsInMainProcess();
|
||||
mozilla::ipc::AssertIsInMainOrSocketProcess();
|
||||
AssertIsOnBackgroundThread();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
include protocol PBackground;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
|
@ -17,6 +19,9 @@ namespace net {
|
|||
*/
|
||||
nested(upto inside_cpow) sync protocol PSocketProcessBridge
|
||||
{
|
||||
parent:
|
||||
async InitBackground(Endpoint<PBackgroundParent> aEndpoint);
|
||||
|
||||
both:
|
||||
async Test();
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@ bool SocketProcessBridgeChild::Create(
|
|||
|
||||
// static
|
||||
already_AddRefed<SocketProcessBridgeChild>
|
||||
SocketProcessBridgeChild::GetSinglton() {
|
||||
SocketProcessBridgeChild::GetSingleton() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!sSocketProcessBridgeChild) {
|
||||
|
@ -79,7 +79,8 @@ void SocketProcessBridgeChild::EnsureSocketProcessBridge(
|
|||
}
|
||||
|
||||
SocketProcessBridgeChild::SocketProcessBridgeChild(
|
||||
Endpoint<PSocketProcessBridgeChild>&& aEndpoint) {
|
||||
Endpoint<PSocketProcessBridgeChild>&& aEndpoint)
|
||||
: mShuttingDown(false) {
|
||||
LOG(("CONSTRUCT SocketProcessBridgeChild::SocketProcessBridgeChild\n"));
|
||||
|
||||
mInited = aEndpoint.Bind(this);
|
||||
|
@ -92,6 +93,8 @@ SocketProcessBridgeChild::SocketProcessBridgeChild(
|
|||
if (os) {
|
||||
os->AddObserver(this, "content-child-shutdown", false);
|
||||
}
|
||||
|
||||
mSocketProcessPid = aEndpoint.OtherPid();
|
||||
}
|
||||
|
||||
SocketProcessBridgeChild::~SocketProcessBridgeChild() {
|
||||
|
@ -112,6 +115,7 @@ void SocketProcessBridgeChild::ActorDestroy(ActorDestroyReason aWhy) {
|
|||
MessageLoop::current()->PostTask(
|
||||
NewRunnableMethod("net::SocketProcessBridgeChild::DeferredDestroy", this,
|
||||
&SocketProcessBridgeChild::DeferredDestroy));
|
||||
mShuttingDown = true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -23,14 +23,16 @@ class SocketProcessBridgeChild final : public PSocketProcessBridgeChild,
|
|||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static bool Create(Endpoint<PSocketProcessBridgeChild>&& aEndpoint);
|
||||
static already_AddRefed<SocketProcessBridgeChild> GetSinglton();
|
||||
static already_AddRefed<SocketProcessBridgeChild> GetSingleton();
|
||||
static void EnsureSocketProcessBridge(std::function<void()>&& aOnSuccess,
|
||||
std::function<void()>&& aOnFailure);
|
||||
|
||||
mozilla::ipc::IPCResult RecvTest() override;
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
void DeferredDestroy();
|
||||
bool IsShuttingDown() const { return mShuttingDown; };
|
||||
bool Inited() const { return mInited; };
|
||||
ProcessId SocketProcessPid() const { return mSocketProcessPid; };
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(SocketProcessBridgeChild);
|
||||
|
@ -39,7 +41,9 @@ class SocketProcessBridgeChild final : public PSocketProcessBridgeChild,
|
|||
virtual ~SocketProcessBridgeChild();
|
||||
|
||||
static StaticRefPtr<SocketProcessBridgeChild> sSocketProcessBridgeChild;
|
||||
bool mShuttingDown;
|
||||
bool mInited = false;
|
||||
ProcessId mSocketProcessPid;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "SocketProcessBridgeParent.h"
|
||||
#include "SocketProcessLogging.h"
|
||||
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
#include "SocketProcessChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -33,6 +34,16 @@ mozilla::ipc::IPCResult SocketProcessBridgeParent::RecvTest() {
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult SocketProcessBridgeParent::RecvInitBackground(
|
||||
Endpoint<PBackgroundParent>&& aEndpoint) {
|
||||
LOG(("SocketProcessBridgeParent::RecvInitBackground mId=%d\n", mId));
|
||||
if (!ipc::BackgroundParent::Alloc(nullptr, std::move(aEndpoint))) {
|
||||
return IPC_FAIL(this, "BackgroundParent::Alloc failed");
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void SocketProcessBridgeParent::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
LOG(("SocketProcessBridgeParent::ActorDestroy mId=%d\n", mId));
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ class SocketProcessBridgeParent final : public PSocketProcessBridgeParent {
|
|||
ProcessId aId, Endpoint<PSocketProcessBridgeParent>&& aEndpoint);
|
||||
|
||||
mozilla::ipc::IPCResult RecvTest() override;
|
||||
mozilla::ipc::IPCResult RecvInitBackground(
|
||||
Endpoint<PBackgroundParent>&& aEndpoint) override;
|
||||
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
void DeferredDestroy();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче