Bug 1340921 - Introduce PMemoryStream for having PBlob and Multi-e10s happy - part 5 - Make MemoryBlobImpl::DataOwner cloneable, r=mrbkap a=gchang
--- a/dom/file/MemoryBlobImpl.cpp
+++ b/dom/file/MemoryBlobImpl.cpp
@@ -13,16 +13,17 @@ namespace mozilla {
namespace dom {
NS_IMPL_ADDREF(MemoryBlobImpl::DataOwnerAdapter)
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)
NS_INTERFACE_MAP_END
nsresult MemoryBlobImpl::DataOwnerAdapter::Create(DataOwner* aDataOwner,
uint32_t aStart,
uint32_t aLength,
--- a/dom/file/MemoryBlobImpl.h
+++ b/dom/file/MemoryBlobImpl.h
@@ -6,16 +6,17 @@
#ifndef mozilla_dom_MemoryBlobImpl_h
#define mozilla_dom_MemoryBlobImpl_h
#include "mozilla/dom/BaseBlobImpl.h"
#include "mozilla/LinkedList.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPtr.h"
+#include "nsICloneableInputStream.h"
#include "nsIInputStream.h"
#include "nsIIPCSerializableInputStream.h"
#include "nsIMemoryReporter.h"
#include "nsISeekableStream.h"
namespace mozilla {
namespace dom {
@@ -92,53 +93,58 @@ public:
static mozilla::StaticMutex sDataOwnerMutex;
static mozilla::StaticAutoPtr<mozilla::LinkedList<DataOwner> > sDataOwners;
static bool sMemoryReporterRegistered;
void* mData;
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:
static nsresult Create(DataOwner* aDataOwner,
uint32_t aStart,
uint32_t aLength,
nsIInputStream** _retval);
NS_DECL_THREADSAFE_ISUPPORTS
// 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.
NS_FORWARD_NSIIPCSERIALIZABLEINPUTSTREAM(mSerializableInputStream->)
private:
~DataOwnerAdapter() {}
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!");
}
RefPtr<DataOwner> mDataOwner;
nsCOMPtr<nsIInputStream> mStream;
nsCOMPtr<nsISeekableStream> mSeekableStream;
nsCOMPtr<nsIIPCSerializableInputStream> mSerializableInputStream;
+ nsCOMPtr<nsICloneableInputStream> mCloneableInputStream;
};
private:
// Create slice
MemoryBlobImpl(const MemoryBlobImpl* aOther, uint64_t aStart,
uint64_t aLength, const nsAString& aContentType)
: BaseBlobImpl(aContentType, aOther->mStart + aStart, aLength)
, mDataOwner(aOther->mDataOwner)