Backed out changeset 79004346238d - wrong version of patch for bug 1211266
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 25 Nov 2015 17:44:30 +0000
changeset 274261 2ba34b52df6b222130935f2bb0a6b99eadf0c2c8
parent 274260 f2f41c4ca5fa4bb4f91a16b6267ed8600b795692
child 274262 8405467ea7adc556cf29e677243ed86a5bf0e1bb
push idunknown
push userunknown
push dateunknown
bugs1211266
milestone45.0a1
backs out79004346238d8aa8e571105ae9150b8a432aad19
Backed out changeset 79004346238d - wrong version of patch for bug 1211266
dom/base/StructuredCloneHolder.cpp
dom/ipc/Blob.cpp
dom/ipc/BlobChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PBlob.ipdl
ipc/glue/BackgroundParentImpl.cpp
ipc/glue/BackgroundParentImpl.h
--- a/dom/base/StructuredCloneHolder.cpp
+++ b/dom/base/StructuredCloneHolder.cpp
@@ -553,25 +553,24 @@ StructuredCloneHolder::WriteFullySeriali
 namespace {
 
 // Recursive!
 already_AddRefed<BlobImpl>
 EnsureBlobForBackgroundManager(BlobImpl* aBlobImpl,
                                PBackgroundChild* aManager = nullptr)
 {
   MOZ_ASSERT(aBlobImpl);
-  RefPtr<BlobImpl> blobImpl = aBlobImpl;
 
   if (!aManager) {
     aManager = BackgroundChild::GetForCurrentThread();
-    if (!aManager) {
-      return blobImpl.forget();
-    }
+    MOZ_ASSERT(aManager);
   }
 
+  RefPtr<BlobImpl> blobImpl = aBlobImpl;
+
   const nsTArray<RefPtr<BlobImpl>>* subBlobImpls =
     aBlobImpl->GetSubBlobImpls();
 
   if (!subBlobImpls || !subBlobImpls->Length()) {
     if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryObject(blobImpl)) {
       // Always make sure we have a blob from an actor we can use on this
       // thread.
       BlobChild* blobChild = BlobChild::GetOrCreate(aManager, blobImpl);
@@ -666,18 +665,16 @@ WriteBlob(JSStructuredCloneWriter* aWrit
 {
   MOZ_ASSERT(aWriter);
   MOZ_ASSERT(aBlob);
   MOZ_ASSERT(aHolder);
 
   RefPtr<BlobImpl> blobImpl = EnsureBlobForBackgroundManager(aBlob->Impl());
   MOZ_ASSERT(blobImpl);
 
-  MOZ_ALWAYS_TRUE(NS_SUCCEEDED(blobImpl->SetMutable(false)));
-
   // We store the position of the blobImpl in the array as index.
   if (JS_WriteUint32Pair(aWriter, SCTAG_DOM_BLOB,
                          aHolder->BlobImpls().Length())) {
     aHolder->BlobImpls().AppendElement(blobImpl);
     return true;
   }
 
   return false;
--- a/dom/ipc/Blob.cpp
+++ b/dom/ipc/Blob.cpp
@@ -1748,43 +1748,48 @@ class BlobChild::RemoteBlobImpl
   , public nsIRemoteBlob
 {
 protected:
   class CreateStreamHelper;
 
   BlobChild* mActor;
   nsCOMPtr<nsIEventTarget> mActorTarget;
 
-  // We use this pointer to keep a live a blobImpl coming from a different
-  // process until this one is fully created. We set it to null when
-  // SendCreatedFromKnownBlob() is received. This is used only with KnownBlob
-  // params in the CTOR of a IPC BlobImpl.
-  RefPtr<BlobImpl> mDifferentProcessBlobImpl;
-
   RefPtr<BlobImpl> mSameProcessBlobImpl;
 
   const bool mIsSlice;
 
 public:
   // For File.
   RemoteBlobImpl(BlobChild* aActor,
-                 BlobImpl* aRemoteBlobImpl,
                  const nsAString& aName,
                  const nsAString& aContentType,
                  uint64_t aLength,
                  int64_t aModDate,
-                 BlobDirState aDirState,
-                 bool aIsSameProcessBlob);
+                 BlobDirState aDirState);
 
   // For Blob.
   RemoteBlobImpl(BlobChild* aActor,
-                 BlobImpl* aRemoteBlobImpl,
+                 const nsAString& aContentType,
+                 uint64_t aLength);
+
+  // For same-process blobs.
+  RemoteBlobImpl(BlobChild* aActor,
+                 BlobImpl* aSameProcessBlobImpl,
+                 const nsAString& aName,
                  const nsAString& aContentType,
                  uint64_t aLength,
-                 bool aIsSameProcessBlob);
+                 int64_t aModDate,
+                 BlobDirState aDirState);
+
+  // For same-process blobs.
+  RemoteBlobImpl(BlobChild* aActor,
+                 BlobImpl* aSameProcessBlobImpl,
+                 const nsAString& aContentType,
+                 uint64_t aLength);
 
   // For mystery blobs.
   explicit
   RemoteBlobImpl(BlobChild* aActor);
 
   void
   NoteDyingActor();
 
@@ -1847,23 +1852,16 @@ public:
   SetMutable(bool aMutable) override;
 
   virtual BlobChild*
   GetBlobChild() override;
 
   virtual BlobParent*
   GetBlobParent() override;
 
-  void
-  NullifyDifferentProcessBlobImpl()
-  {
-    MOZ_ASSERT(mDifferentProcessBlobImpl);
-    mDifferentProcessBlobImpl = nullptr;
-  }
-
 protected:
   // For SliceImpl.
   RemoteBlobImpl(const nsAString& aContentType, uint64_t aLength);
 
   ~RemoteBlobImpl()
   {
     MOZ_ASSERT_IF(mActorTarget,
                   EventTargetIsOnCurrentThread(mActorTarget));
@@ -2083,53 +2081,66 @@ private:
 };
 
 /*******************************************************************************
  * BlobChild::RemoteBlobImpl
  ******************************************************************************/
 
 BlobChild::
 RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor,
-                               BlobImpl* aRemoteBlobImpl,
                                const nsAString& aName,
                                const nsAString& aContentType,
                                uint64_t aLength,
                                int64_t aModDate,
-                               BlobDirState aDirState,
-                               bool aIsSameProcessBlob)
+                               BlobDirState aDirState)
   : BlobImplBase(aName, aContentType, aLength, aModDate, aDirState)
   , mIsSlice(false)
 {
-  if (aIsSameProcessBlob) {
-    MOZ_ASSERT(aRemoteBlobImpl);
-    mSameProcessBlobImpl = aRemoteBlobImpl;
-    MOZ_ASSERT(gProcessType == GeckoProcessType_Default);
-  } else {
-    mDifferentProcessBlobImpl = aRemoteBlobImpl;
-  }
+  CommonInit(aActor);
+}
+
+BlobChild::
+RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor,
+                               const nsAString& aContentType,
+                               uint64_t aLength)
+  : BlobImplBase(aContentType, aLength)
+  , mIsSlice(false)
+{
+  CommonInit(aActor);
+}
+
+BlobChild::
+RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor,
+                               BlobImpl* aSameProcessBlobImpl,
+                               const nsAString& aName,
+                               const nsAString& aContentType,
+                               uint64_t aLength,
+                               int64_t aModDate,
+                               BlobDirState aDirState)
+  : BlobImplBase(aName, aContentType, aLength, aModDate, aDirState)
+  , mSameProcessBlobImpl(aSameProcessBlobImpl)
+  , mIsSlice(false)
+{
+  MOZ_ASSERT(aSameProcessBlobImpl);
+  MOZ_ASSERT(gProcessType == GeckoProcessType_Default);
 
   CommonInit(aActor);
 }
 
 BlobChild::
 RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor,
-                               BlobImpl* aRemoteBlobImpl,
+                               BlobImpl* aSameProcessBlobImpl,
                                const nsAString& aContentType,
-                               uint64_t aLength,
-                               bool aIsSameProcessBlob)
+                               uint64_t aLength)
   : BlobImplBase(aContentType, aLength)
+  , mSameProcessBlobImpl(aSameProcessBlobImpl)
   , mIsSlice(false)
 {
-  if (aIsSameProcessBlob) {
-    MOZ_ASSERT(aRemoteBlobImpl);
-    mSameProcessBlobImpl = aRemoteBlobImpl;
-    MOZ_ASSERT(gProcessType == GeckoProcessType_Default);
-  } else {
-    mDifferentProcessBlobImpl = aRemoteBlobImpl;
-  }
+  MOZ_ASSERT(aSameProcessBlobImpl);
+  MOZ_ASSERT(gProcessType == GeckoProcessType_Default);
 
   CommonInit(aActor);
 }
 
 BlobChild::
 RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor)
   : BlobImplBase(EmptyString(), EmptyString(), UINT64_MAX, INT64_MAX)
   , mIsSlice(false)
@@ -3025,22 +3036,20 @@ BlobChild::CommonInit(BlobChild* aOther,
   RefPtr<RemoteBlobImpl> remoteBlob;
   if (otherImpl->IsFile()) {
     nsString name;
     otherImpl->GetName(name);
 
     int64_t modDate = otherImpl->GetLastModified(rv);
     MOZ_ASSERT(!rv.Failed());
 
-    remoteBlob = new RemoteBlobImpl(this, otherImpl, name, contentType, length,
-                                    modDate, otherImpl->GetDirState(),
-                                    false /* SameProcessBlobImpl */);
+    remoteBlob = new RemoteBlobImpl(this, name, contentType, length, modDate,
+                                    otherImpl->GetDirState());
   } else {
-    remoteBlob = new RemoteBlobImpl(this, otherImpl, contentType, length,
-                                    false /* SameProcessBlobImpl */);
+    remoteBlob = new RemoteBlobImpl(this, contentType, length);
   }
 
   CommonInit(aOther->ParentID(), remoteBlob);
 }
 
 void
 BlobChild::CommonInit(const ChildBlobConstructorParams& aParams)
 {
@@ -3059,32 +3068,29 @@ BlobChild::CommonInit(const ChildBlobCon
 
   RefPtr<RemoteBlobImpl> remoteBlob;
 
   switch (paramsType) {
     case AnyBlobConstructorParams::TNormalBlobConstructorParams: {
       const NormalBlobConstructorParams& params =
         blobParams.get_NormalBlobConstructorParams();
       remoteBlob =
-        new RemoteBlobImpl(this, nullptr, params.contentType(), params.length(),
-                           false /* SameProcessBlobImpl */);
+        new RemoteBlobImpl(this, params.contentType(), params.length());
       break;
     }
 
     case AnyBlobConstructorParams::TFileBlobConstructorParams: {
       const FileBlobConstructorParams& params =
         blobParams.get_FileBlobConstructorParams();
       remoteBlob = new RemoteBlobImpl(this,
-                                      nullptr,
                                       params.name(),
                                       params.contentType(),
                                       params.length(),
                                       params.modDate(),
-                                      BlobDirState(params.dirState()),
-                                      false /* SameProcessBlobImpl */);
+                                      BlobDirState(params.dirState()));
       break;
     }
 
     case AnyBlobConstructorParams::TSameProcessBlobConstructorParams: {
       MOZ_ASSERT(gProcessType == GeckoProcessType_Default);
 
       const SameProcessBlobConstructorParams& params =
         blobParams.get_SameProcessBlobConstructorParams();
@@ -3109,21 +3115,19 @@ BlobChild::CommonInit(const ChildBlobCon
 
         remoteBlob =
           new RemoteBlobImpl(this,
                              blobImpl,
                              name,
                              contentType,
                              size,
                              lastModifiedDate,
-                             blobImpl->GetDirState(),
-                             true /* SameProcessBlobImpl */);
+                             blobImpl->GetDirState());
       } else {
-        remoteBlob = new RemoteBlobImpl(this, blobImpl, contentType, size,
-                                        true /* SameProcessBlobImpl */);
+        remoteBlob = new RemoteBlobImpl(this, blobImpl, contentType, size);
       }
 
       break;
     }
 
     case AnyBlobConstructorParams::TMysteryBlobConstructorParams: {
       remoteBlob = new RemoteBlobImpl(this);
       break;
@@ -3583,24 +3587,16 @@ bool
 BlobChild::DeallocPBlobStreamChild(PBlobStreamChild* aActor)
 {
   AssertIsOnOwningThread();
 
   delete static_cast<InputStreamChild*>(aActor);
   return true;
 }
 
-bool
-BlobChild::RecvCreatedFromKnownBlob()
-{
-  // Releasing the other blob now that this blob is fully created.
-  mRemoteBlobImpl->NullifyDifferentProcessBlobImpl();
-  return true;
-}
-
 /*******************************************************************************
  * BlobParent
  ******************************************************************************/
 
 BlobParent::BlobParent(nsIContentParent* aManager, IDTableEntry* aIDTableEntry)
   : mBackgroundManager(nullptr)
   , mContentManager(aManager)
 {
--- a/dom/ipc/BlobChild.h
+++ b/dom/ipc/BlobChild.h
@@ -215,19 +215,16 @@ private:
   ActorDestroy(ActorDestroyReason aWhy) override;
 
   virtual PBlobStreamChild*
   AllocPBlobStreamChild(const uint64_t& aStart,
                         const uint64_t& aLength) override;
 
   virtual bool
   DeallocPBlobStreamChild(PBlobStreamChild* aActor) override;
-
-  virtual bool
-  RecvCreatedFromKnownBlob() override;
 };
 
 // Only let ContentChild call BlobChild::Startup() and ensure that
 // ContentChild can't access any other BlobChild internals.
 class BlobChild::FriendKey final
 {
   friend class ContentChild;
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3510,28 +3510,16 @@ ContentParent::AllocPBlobParent(const Bl
 }
 
 bool
 ContentParent::DeallocPBlobParent(PBlobParent* aActor)
 {
     return nsIContentParent::DeallocPBlobParent(aActor);
 }
 
-bool
-ContentParent::RecvPBlobConstructor(PBlobParent* aActor,
-                                    const BlobConstructorParams& aParams)
-{
-  const ParentBlobConstructorParams& params = aParams.get_ParentBlobConstructorParams();
-  if (params.blobParams().type() == AnyBlobConstructorParams::TKnownBlobConstructorParams) {
-    return aActor->SendCreatedFromKnownBlob();
-  }
-
-  return true;
-}
-
 mozilla::PRemoteSpellcheckEngineParent *
 ContentParent::AllocPRemoteSpellcheckEngineParent()
 {
     mozilla::RemoteSpellcheckEngineParent *parent = new mozilla::RemoteSpellcheckEngineParent();
     return parent;
 }
 
 bool
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -643,19 +643,16 @@ private:
 
     virtual bool
     DeallocPFileSystemRequestParent(PFileSystemRequestParent*) override;
 
     virtual PBlobParent* AllocPBlobParent(const BlobConstructorParams& aParams)
                                           override;
     virtual bool DeallocPBlobParent(PBlobParent* aActor) override;
 
-    virtual bool RecvPBlobConstructor(PBlobParent* aActor,
-                                      const BlobConstructorParams& params) override;
-
     virtual bool DeallocPCrashReporterParent(PCrashReporterParent* crashreporter) override;
 
     virtual bool RecvGetRandomValues(const uint32_t& length,
                                      InfallibleTArray<uint8_t>* randomValues) override;
 
     virtual bool RecvIsSecureURI(const uint32_t& aType, const URIParams& aURI,
                                  const uint32_t& aFlags, bool* aIsSecureURI) override;
 
--- a/dom/ipc/PBlob.ipdl
+++ b/dom/ipc/PBlob.ipdl
@@ -40,17 +40,12 @@ parent:
 
   // Use only for testing!
   sync GetFileId()
     returns (int64_t fileId);
 
   // Use only for testing!
   sync GetFilePath()
     returns (nsString filePath);
-
-child:
-  // This method must be called by the parent when the PBlobParent is fully
-  // created in order to release the known blob.
-  CreatedFromKnownBlob();
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/ipc/glue/BackgroundParentImpl.cpp
+++ b/ipc/glue/BackgroundParentImpl.cpp
@@ -8,17 +8,16 @@
 #include "FileDescriptorSetParent.h"
 #ifdef MOZ_WEBRTC
 #include "CamerasParent.h"
 #endif
 #include "mozilla/media/MediaParent.h"
 #include "mozilla/AppProcessChecker.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/ContentParent.h"
-#include "mozilla/dom/DOMTypes.h"
 #include "mozilla/dom/NuwaParent.h"
 #include "mozilla/dom/PBlobParent.h"
 #include "mozilla/dom/MessagePortParent.h"
 #include "mozilla/dom/ServiceWorkerRegistrar.h"
 #include "mozilla/dom/asmjscache/AsmJSCache.h"
 #include "mozilla/dom/cache/ActorUtils.h"
 #include "mozilla/dom/indexedDB/ActorsParent.h"
 #include "mozilla/dom/ipc/BlobParent.h"
@@ -239,28 +238,16 @@ BackgroundParentImpl::DeallocPBlobParent
   AssertIsInMainProcess();
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(aActor);
 
   mozilla::dom::BlobParent::Destroy(aActor);
   return true;
 }
 
-bool
-BackgroundParentImpl::RecvPBlobConstructor(PBlobParent* aActor,
-                                           const BlobConstructorParams& aParams)
-{
-  const ParentBlobConstructorParams& params = aParams;
-  if (params.blobParams().type() == AnyBlobConstructorParams::TKnownBlobConstructorParams) {
-    return aActor->SendCreatedFromKnownBlob();
-  }
-
-  return true;
-}
-
 PFileDescriptorSetParent*
 BackgroundParentImpl::AllocPFileDescriptorSetParent(
                                           const FileDescriptor& aFileDescriptor)
 {
   AssertIsInMainProcess();
   AssertIsOnBackgroundThread();
 
   return new FileDescriptorSetParent(aFileDescriptor);
--- a/ipc/glue/BackgroundParentImpl.h
+++ b/ipc/glue/BackgroundParentImpl.h
@@ -59,20 +59,16 @@ protected:
                                         override;
 
   virtual PBlobParent*
   AllocPBlobParent(const BlobConstructorParams& aParams) override;
 
   virtual bool
   DeallocPBlobParent(PBlobParent* aActor) override;
 
-  virtual bool
-  RecvPBlobConstructor(PBlobParent* aActor,
-                       const BlobConstructorParams& params) override;
-
   virtual PFileDescriptorSetParent*
   AllocPFileDescriptorSetParent(const FileDescriptor& aFileDescriptor)
                                 override;
 
   virtual bool
   DeallocPFileDescriptorSetParent(PFileDescriptorSetParent* aActor)
                                   override;