зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1254730 - patch 2 - Better comments and a better management of lifetime of ChannelEvents, r=michal
This commit is contained in:
Родитель
c0ff981fd3
Коммит
e0a0cfb614
|
@ -52,10 +52,10 @@ class ChannelEventQueue final
|
|||
// automatically when EndForcedQueueing and/or Resume is called.
|
||||
//
|
||||
// @param aCallback - the ChannelEvent
|
||||
// @param aAssertWhenNotQueued - this optional param will be used in an
|
||||
// @param aAssertionWhenNotQueued - this optional param will be used in an
|
||||
// assertion when the event is executed directly.
|
||||
inline void RunOrEnqueue(ChannelEvent* aCallback,
|
||||
bool aAssertWhenNotQueued = true);
|
||||
bool aAssertionWhenNotQueued = false);
|
||||
inline nsresult PrependEvents(nsTArray<UniquePtr<ChannelEvent>>& aEvents);
|
||||
|
||||
// After StartForcedQueueing is called, RunOrEnqueue() will start enqueuing
|
||||
|
@ -109,10 +109,13 @@ class ChannelEventQueue final
|
|||
|
||||
inline void
|
||||
ChannelEventQueue::RunOrEnqueue(ChannelEvent* aCallback,
|
||||
bool aAssertWhenNotQueued)
|
||||
bool aAssertionWhenNotQueued)
|
||||
{
|
||||
MOZ_ASSERT(aCallback);
|
||||
|
||||
// To avoid leaks.
|
||||
UniquePtr<ChannelEvent> event(aCallback);
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
|
@ -121,13 +124,13 @@ ChannelEventQueue::RunOrEnqueue(ChannelEvent* aCallback,
|
|||
"Should always enqueue if ChannelEventQueue not empty");
|
||||
|
||||
if (enqueue) {
|
||||
mEventQueue.AppendElement(aCallback);
|
||||
mEventQueue.AppendElement(Move(event));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(aAssertWhenNotQueued);
|
||||
aCallback->Run();
|
||||
MOZ_RELEASE_ASSERT(!aAssertionWhenNotQueued);
|
||||
event->Run();
|
||||
}
|
||||
|
||||
inline void
|
||||
|
|
|
@ -377,7 +377,7 @@ FTPChannelChild::RecvOnDataAvailable(const nsresult& channelStatus,
|
|||
|
||||
mEventQ->RunOrEnqueue(new FTPDataAvailableEvent(this, channelStatus, data,
|
||||
offset, count),
|
||||
!mDivertingToParent);
|
||||
mDivertingToParent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -632,7 +632,7 @@ FTPChannelChild::RecvFlushedForDiversion()
|
|||
LOG(("FTPChannelChild::RecvFlushedForDiversion [this=%p]\n", this));
|
||||
MOZ_ASSERT(mDivertingToParent);
|
||||
|
||||
mEventQ->RunOrEnqueue(new FTPFlushedForDiversionEvent(this));
|
||||
mEventQ->RunOrEnqueue(new FTPFlushedForDiversionEvent(this), true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -611,7 +611,7 @@ HttpChannelChild::RecvOnTransportAndData(const nsresult& channelStatus,
|
|||
transportStatus, progress,
|
||||
progressMax, data, offset,
|
||||
count),
|
||||
!mDivertingToParent);
|
||||
mDivertingToParent);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -810,7 +810,8 @@ HttpChannelChild::RecvOnStopRequest(const nsresult& channelStatus,
|
|||
MOZ_RELEASE_ASSERT(!mFlushedForDiversion,
|
||||
"Should not be receiving any more callbacks from parent!");
|
||||
|
||||
mEventQ->RunOrEnqueue(new StopRequestEvent(this, channelStatus, timing));
|
||||
mEventQ->RunOrEnqueue(new StopRequestEvent(this, channelStatus, timing),
|
||||
mDivertingToParent);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1339,7 +1340,7 @@ HttpChannelChild::RecvFlushedForDiversion()
|
|||
LOG(("HttpChannelChild::RecvFlushedForDiversion [this=%p]\n", this));
|
||||
MOZ_RELEASE_ASSERT(mDivertingToParent);
|
||||
|
||||
mEventQ->RunOrEnqueue(new HttpFlushedForDiversionEvent(this));
|
||||
mEventQ->RunOrEnqueue(new HttpFlushedForDiversionEvent(this), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче