Bug 1340921 - Introduce PMemoryStream for having PBlob and Multi-e10s happy - part 5 - Make MemoryBlobImpl::DataOwner cloneable, r=mrbkap a=gchang
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 29 Mar 2017 10:40:39 +0200
changeset 375672 d0b605e7f5c7e2b6f69fa39c37f5bdef06e038ca
parent 375671 02a7a514a2655c5ef44bdb2b2d5f4af926f09e0f
child 375673 c53411a2c11f43f6ea567fbb38efcf79b08bcf28
push id11002
push usercbook@mozilla.com
push dateMon, 03 Apr 2017 09:29:08 +0000
treeherdermozilla-aurora@c53411a2c11f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, gchang
bugs1340921
milestone54.0a2
Bug 1340921 - Introduce PMemoryStream for having PBlob and Multi-e10s happy - part 5 - Make MemoryBlobImpl::DataOwner cloneable, r=mrbkap a=gchang
dom/file/MemoryBlobImpl.cpp
dom/file/MemoryBlobImpl.h
--- 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)