Bug 1340921 - Introduce PMemoryStream for having PBlob and Multi-e10s happy - part 5 - Make MemoryBlobImpl::DataOwner cloneable, r=mrbkap

This commit is contained in:
Andrea Marchesini 2017-03-29 10:40:39 +02:00
parent f6b3cb0b74
commit 1feb18fd09
2 changed files with 13 additions and 6 deletions

View File

@ -18,6 +18,7 @@ NS_IMPL_RELEASE(MemoryBlobImpl::DataOwnerAdapter)
NS_INTERFACE_MAP_BEGIN(MemoryBlobImpl::DataOwnerAdapter)
NS_INTERFACE_MAP_ENTRY(nsIInputStream)
NS_INTERFACE_MAP_ENTRY(nsISeekableStream)
NS_INTERFACE_MAP_ENTRY(nsICloneableInputStream)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIIPCSerializableInputStream,
mSerializableInputStream)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInputStream)

View File

@ -11,6 +11,7 @@
#include "mozilla/LinkedList.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPtr.h"
#include "nsICloneableInputStream.h"
#include "nsIInputStream.h"
#include "nsIIPCSerializableInputStream.h"
#include "nsIMemoryReporter.h"
@ -97,9 +98,10 @@ public:
uint64_t mLength;
};
class DataOwnerAdapter final : public nsIInputStream,
public nsISeekableStream,
public nsIIPCSerializableInputStream
class DataOwnerAdapter final : public nsIInputStream
, public nsISeekableStream
, public nsIIPCSerializableInputStream
, public nsICloneableInputStream
{
typedef MemoryBlobImpl::DataOwner DataOwner;
public:
@ -113,6 +115,7 @@ public:
// These are mandatory.
NS_FORWARD_NSIINPUTSTREAM(mStream->)
NS_FORWARD_NSISEEKABLESTREAM(mSeekableStream->)
NS_FORWARD_NSICLONEABLEINPUTSTREAM(mCloneableInputStream->)
// This is optional. We use a conditional QI to keep it from being called
// if the underlying stream doesn't support it.
@ -123,9 +126,11 @@ public:
DataOwnerAdapter(DataOwner* aDataOwner,
nsIInputStream* aStream)
: mDataOwner(aDataOwner), mStream(aStream),
mSeekableStream(do_QueryInterface(aStream)),
mSerializableInputStream(do_QueryInterface(aStream))
: mDataOwner(aDataOwner)
, mStream(aStream)
, mSeekableStream(do_QueryInterface(aStream))
, mSerializableInputStream(do_QueryInterface(aStream))
, mCloneableInputStream(do_QueryInterface(aStream))
{
MOZ_ASSERT(mSeekableStream, "Somebody gave us the wrong stream!");
}
@ -134,6 +139,7 @@ public:
nsCOMPtr<nsIInputStream> mStream;
nsCOMPtr<nsISeekableStream> mSeekableStream;
nsCOMPtr<nsIIPCSerializableInputStream> mSerializableInputStream;
nsCOMPtr<nsICloneableInputStream> mCloneableInputStream;
};
private: