Bug 1399466 - IPCBlobInputStream should not use STS to read from the remote Stream, but DOMFile thread instead, r=smaug
This commit is contained in:
@@ -8,10 +8,11 @@
|
||||
#include "IPCBlobInputStreamChild.h"
|
||||
#include "IPCBlobInputStreamStorage.h"
|
||||
#include "mozilla/ipc/InputStreamParams.h"
|
||||
#include "IPCBlobInputStreamThread.h"
|
||||
#include "nsIAsyncInputStream.h"
|
||||
#include "nsIStreamTransportService.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIAsyncOutputStream.h"
|
||||
#include "nsIPipe.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "SlicedInputStream.h"
|
||||
|
||||
@@ -20,8 +21,6 @@ namespace dom {
|
||||
|
||||
namespace {
|
||||
|
||||
static NS_DEFINE_CID(kStreamTransportServiceCID, NS_STREAMTRANSPORTSERVICE_CID);
|
||||
|
||||
class InputStreamCallbackRunnable final : public CancelableRunnable
|
||||
{
|
||||
public:
|
||||
@@ -651,32 +650,25 @@ IPCBlobInputStream::EnsureAsyncRemoteStream()
|
||||
|
||||
nsCOMPtr<nsIAsyncInputStream> asyncStream = do_QueryInterface(mRemoteStream);
|
||||
if (!asyncStream || !nonBlocking) {
|
||||
nsCOMPtr<nsIStreamTransportService> sts =
|
||||
do_GetService(kStreamTransportServiceCID, &rv);
|
||||
// Let's make the stream async using the DOMFile thread.
|
||||
nsCOMPtr<nsIAsyncInputStream> pipeIn;
|
||||
nsCOMPtr<nsIAsyncOutputStream> pipeOut;
|
||||
rv = NS_NewPipe2(getter_AddRefs(pipeIn),
|
||||
getter_AddRefs(pipeOut),
|
||||
true, true);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITransport> transport;
|
||||
rv = sts->CreateInputTransport(mRemoteStream,
|
||||
/* aStartOffset */ 0,
|
||||
/* aReadLimit */ -1,
|
||||
/* aCloseWhenDone */ true,
|
||||
getter_AddRefs(transport));
|
||||
nsCOMPtr<nsIEventTarget> target =
|
||||
IPCBlobInputStreamThread::GetOrCreate()->EventTarget();
|
||||
rv = NS_AsyncCopy(mRemoteStream, pipeOut, target,
|
||||
NS_ASYNCCOPY_VIA_WRITESEGMENTS);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> wrapper;
|
||||
rv = transport->OpenInputStream(/* aFlags */ 0,
|
||||
/* aSegmentSize */ 0,
|
||||
/* aSegmentCount */ 0,
|
||||
getter_AddRefs(wrapper));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
asyncStream = do_QueryInterface(wrapper);
|
||||
asyncStream = pipeIn;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(asyncStream);
|
||||
|
||||
@@ -158,6 +158,12 @@ IPCBlobInputStreamThread::Initialize()
|
||||
}
|
||||
}
|
||||
|
||||
nsIEventTarget*
|
||||
IPCBlobInputStreamThread::EventTarget() const
|
||||
{
|
||||
return mThread;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IPCBlobInputStreamThread::Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
|
||||
@@ -34,6 +34,9 @@ public:
|
||||
void
|
||||
Initialize();
|
||||
|
||||
nsIEventTarget*
|
||||
EventTarget() const;
|
||||
|
||||
private:
|
||||
~IPCBlobInputStreamThread() = default;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user