зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1363877 - Label IPC shmem messages as SystemGroup (r=dvander)
MozReview-Commit-ID: 3I5ny0wxVHI
This commit is contained in:
Родитель
1ed19ed100
Коммит
b71d032b99
|
@ -774,6 +774,7 @@ MessageChannel::Open(Transport* aTransport, MessageLoop* aIOLoop, Side aSide)
|
|||
mWorkerLoop = MessageLoop::current();
|
||||
mWorkerLoopID = mWorkerLoop->id();
|
||||
mWorkerLoop->AddDestructionObserver(this);
|
||||
mListener->SetIsMainThreadProtocol();
|
||||
|
||||
if (!AbstractThread::GetCurrent()) {
|
||||
mWorkerLoop->AddDestructionObserver(
|
||||
|
@ -859,6 +860,7 @@ MessageChannel::CommonThreadOpenInit(MessageChannel *aTargetChan, Side aSide)
|
|||
mWorkerLoop = MessageLoop::current();
|
||||
mWorkerLoopID = mWorkerLoop->id();
|
||||
mWorkerLoop->AddDestructionObserver(this);
|
||||
mListener->SetIsMainThreadProtocol();
|
||||
|
||||
if (!AbstractThread::GetCurrent()) {
|
||||
mWorkerLoop->AddDestructionObserver(
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "mozilla/ipc/MessageChannel.h"
|
||||
#include "mozilla/ipc/Transport.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "mozilla/SystemGroup.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
|
@ -815,6 +816,13 @@ IToplevelProtocol::ShmemDestroyed(const Message& aMsg)
|
|||
already_AddRefed<nsIEventTarget>
|
||||
IToplevelProtocol::GetMessageEventTarget(const Message& aMsg)
|
||||
{
|
||||
if (IsMainThreadProtocol() && SystemGroup::Initialized()) {
|
||||
if (aMsg.type() == SHMEM_CREATED_MESSAGE_TYPE ||
|
||||
aMsg.type() == SHMEM_DESTROYED_MESSAGE_TYPE) {
|
||||
return do_AddRef(SystemGroup::EventTargetFor(TaskCategory::Other));
|
||||
}
|
||||
}
|
||||
|
||||
int32_t route = aMsg.routing_id();
|
||||
|
||||
Maybe<MutexAutoLock> lock;
|
||||
|
|
|
@ -386,6 +386,10 @@ public:
|
|||
GetActorEventTarget();
|
||||
|
||||
virtual void OnChannelReceivedMessage(const Message& aMsg) {}
|
||||
|
||||
bool IsMainThreadProtocol() const { return mIsMainThreadProtocol; }
|
||||
void SetIsMainThreadProtocol() { mIsMainThreadProtocol = NS_IsMainThread(); }
|
||||
|
||||
protected:
|
||||
// Override this method in top-level protocols to change the event target
|
||||
// for a new actor (and its sub-actors).
|
||||
|
@ -413,6 +417,7 @@ protected:
|
|||
int32_t mLastRouteId;
|
||||
IDMap<Shmem::SharedMemory*> mShmemMap;
|
||||
Shmem::id_t mLastShmemId;
|
||||
bool mIsMainThreadProtocol;
|
||||
|
||||
Mutex mEventTargetMutex;
|
||||
IDMap<nsCOMPtr<nsIEventTarget>> mEventTargetMap;
|
||||
|
|
|
@ -22,6 +22,8 @@ public:
|
|||
static void ShutdownStatic();
|
||||
static SystemGroupImpl* Get();
|
||||
|
||||
static bool Initialized() { return !!sSingleton; }
|
||||
|
||||
NS_METHOD_(MozExternalRefCountType) AddRef(void)
|
||||
{
|
||||
return 2;
|
||||
|
@ -76,6 +78,12 @@ SystemGroup::Shutdown()
|
|||
SystemGroupImpl::ShutdownStatic();
|
||||
}
|
||||
|
||||
bool
|
||||
SystemGroup::Initialized()
|
||||
{
|
||||
return SystemGroupImpl::Initialized();
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
SystemGroup::Dispatch(const char* aName,
|
||||
TaskCategory aCategory,
|
||||
|
|
|
@ -34,6 +34,9 @@ class SystemGroup
|
|||
|
||||
static void InitStatic();
|
||||
static void Shutdown();
|
||||
|
||||
// Returns true if SystemGroup has been initialized.
|
||||
static bool Initialized();
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче