mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1247393 - use arrays of UniquePtr in ChannelEventQueue; r=mcmanus
This commit is contained in:
parent
549fe38295
commit
f4e4ca445e
@ -8,8 +8,9 @@
|
||||
#ifndef mozilla_net_ChannelEventQueue_h
|
||||
#define mozilla_net_ChannelEventQueue_h
|
||||
|
||||
#include <nsTArray.h>
|
||||
#include <nsAutoPtr.h>
|
||||
#include "nsTArray.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class nsISupports;
|
||||
class nsIEventTarget;
|
||||
@ -51,7 +52,7 @@ class ChannelEventQueue final
|
||||
// Puts IPDL-generated channel event into queue, to be run later
|
||||
// automatically when EndForcedQueueing and/or Resume is called.
|
||||
inline void Enqueue(ChannelEvent* callback);
|
||||
inline nsresult PrependEvents(nsTArray<nsAutoPtr<ChannelEvent> >& aEvents);
|
||||
inline nsresult PrependEvents(nsTArray<UniquePtr<ChannelEvent>>& aEvents);
|
||||
|
||||
// After StartForcedQueueing is called, ShouldEnqueue() will return true and
|
||||
// no events will be run/flushed until EndForcedQueueing is called.
|
||||
@ -82,7 +83,7 @@ class ChannelEventQueue final
|
||||
void FlushQueue();
|
||||
inline void CompleteResume();
|
||||
|
||||
nsTArray<nsAutoPtr<ChannelEvent> > mEventQueue;
|
||||
nsTArray<UniquePtr<ChannelEvent>> mEventQueue;
|
||||
|
||||
uint32_t mSuspendCount;
|
||||
bool mSuspended;
|
||||
@ -129,14 +130,16 @@ ChannelEventQueue::EndForcedQueueing()
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
ChannelEventQueue::PrependEvents(nsTArray<nsAutoPtr<ChannelEvent> >& aEvents)
|
||||
ChannelEventQueue::PrependEvents(nsTArray<UniquePtr<ChannelEvent>>& aEvents)
|
||||
{
|
||||
if (!mEventQueue.InsertElementsAt(0, aEvents.Length())) {
|
||||
UniquePtr<ChannelEvent>* newEvents =
|
||||
mEventQueue.InsertElementsAt(0, aEvents.Length());
|
||||
if (!newEvents) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < aEvents.Length(); i++) {
|
||||
mEventQueue.ReplaceElementAt(i, aEvents[i].forget());
|
||||
newEvents[i] = Move(aEvents[i]);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ FTPChannelChild::DoOnDataAvailable(const nsresult& channelStatus,
|
||||
|
||||
if (mUnknownDecoderInvolved) {
|
||||
mUnknownDecoderEventQ.AppendElement(
|
||||
new MaybeDivertOnDataFTPEvent(this, data, offset, count));
|
||||
MakeUnique<MaybeDivertOnDataFTPEvent>(this, data, offset, count));
|
||||
}
|
||||
|
||||
// NOTE: the OnDataAvailable contract requires the client to read all the data
|
||||
@ -557,7 +557,7 @@ FTPChannelChild::DoOnStopRequest(const nsresult& aChannelStatus)
|
||||
|
||||
if (mUnknownDecoderInvolved) {
|
||||
mUnknownDecoderEventQ.AppendElement(
|
||||
new MaybeDivertOnStopFTPEvent(this, aChannelStatus));
|
||||
MakeUnique<MaybeDivertOnStopFTPEvent>(this, aChannelStatus));
|
||||
}
|
||||
|
||||
{ // Ensure that all queued ipdl events are dispatched before
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef mozilla_net_FTPChannelChild_h
|
||||
#define mozilla_net_FTPChannelChild_h
|
||||
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/net/PFTPChannelChild.h"
|
||||
#include "mozilla/net/ChannelEventQueue.h"
|
||||
#include "nsBaseChannel.h"
|
||||
@ -126,7 +127,7 @@ private:
|
||||
// If nsUnknownDecoder is involved we queue onDataAvailable (and possibly
|
||||
// OnStopRequest) so that we can divert them if needed when the listener's
|
||||
// OnStartRequest is finally called
|
||||
nsTArray<nsAutoPtr<ChannelEvent>> mUnknownDecoderEventQ;
|
||||
nsTArray<UniquePtr<ChannelEvent>> mUnknownDecoderEventQ;
|
||||
bool mUnknownDecoderInvolved;
|
||||
|
||||
bool mCanceled;
|
||||
|
@ -698,7 +698,7 @@ HttpChannelChild::OnTransportAndData(const nsresult& channelStatus,
|
||||
LOG(("UnknownDecoder is involved queue OnDataAvailable call. [this=%p]",
|
||||
this));
|
||||
mUnknownDecoderEventQ.AppendElement(
|
||||
new MaybeDivertOnDataHttpEvent(this, data, offset, count));
|
||||
MakeUnique<MaybeDivertOnDataHttpEvent>(this, data, offset, count));
|
||||
}
|
||||
|
||||
// Hold queue lock throughout all three calls, else we might process a later
|
||||
@ -885,7 +885,7 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
|
||||
LOG(("UnknownDecoder is involved queue OnStopRequest call. [this=%p]",
|
||||
this));
|
||||
mUnknownDecoderEventQ.AppendElement(
|
||||
new MaybeDivertOnStopHttpEvent(this, channelStatus));
|
||||
MakeUnique<MaybeDivertOnStopHttpEvent>(this, channelStatus));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICompressConvStats> conv = do_QueryInterface(mCompressListener);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef mozilla_net_HttpChannelChild_h
|
||||
#define mozilla_net_HttpChannelChild_h
|
||||
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/net/HttpBaseChannel.h"
|
||||
#include "mozilla/net/PHttpChannelChild.h"
|
||||
#include "mozilla/net/ChannelEventQueue.h"
|
||||
@ -204,7 +205,7 @@ private:
|
||||
// If nsUnknownDecoder is involved OnStartRequest call will be delayed and
|
||||
// this queue keeps OnDataAvailable data until OnStartRequest is finally
|
||||
// called.
|
||||
nsTArray<nsAutoPtr<ChannelEvent>> mUnknownDecoderEventQ;
|
||||
nsTArray<UniquePtr<ChannelEvent>> mUnknownDecoderEventQ;
|
||||
bool mUnknownDecoderInvolved;
|
||||
|
||||
// Once set, OnData and possibly OnStop will be diverted to the parent.
|
||||
|
Loading…
Reference in New Issue
Block a user