diff --git a/dom/base/StructuredCloneHolder.cpp b/dom/base/StructuredCloneHolder.cpp index b069f7d7b1f..6fc6229f2bb 100644 --- a/dom/base/StructuredCloneHolder.cpp +++ b/dom/base/StructuredCloneHolder.cpp @@ -558,15 +558,14 @@ EnsureBlobForBackgroundManager(BlobImpl* aBlobImpl, PBackgroundChild* aManager = nullptr) { MOZ_ASSERT(aBlobImpl); - RefPtr blobImpl = aBlobImpl; if (!aManager) { aManager = BackgroundChild::GetForCurrentThread(); - if (!aManager) { - return blobImpl.forget(); - } + MOZ_ASSERT(aManager); } + RefPtr blobImpl = aBlobImpl; + const nsTArray>* subBlobImpls = aBlobImpl->GetSubBlobImpls(); @@ -671,8 +670,6 @@ WriteBlob(JSStructuredCloneWriter* aWriter, RefPtr 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())) { diff --git a/dom/ipc/Blob.cpp b/dom/ipc/Blob.cpp index 2bfc9ce7427..489a777fe5d 100644 --- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -1753,12 +1753,6 @@ protected: BlobChild* mActor; nsCOMPtr 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 mDifferentProcessBlobImpl; - RefPtr mSameProcessBlobImpl; const bool mIsSlice; @@ -1766,20 +1760,31 @@ protected: 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 @@ -1852,13 +1857,6 @@ public: virtual BlobParent* GetBlobParent() override; - void - NullifyDifferentProcessBlobImpl() - { - MOZ_ASSERT(mDifferentProcessBlobImpl); - mDifferentProcessBlobImpl = nullptr; - } - protected: // For SliceImpl. RemoteBlobImpl(const nsAString& aContentType, uint64_t aLength); @@ -2088,43 +2086,56 @@ private: 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); } @@ -3030,12 +3041,10 @@ BlobChild::CommonInit(BlobChild* aOther, BlobImpl* aBlobImpl) 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); @@ -3064,8 +3073,7 @@ BlobChild::CommonInit(const ChildBlobConstructorParams& aParams) 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; } @@ -3073,13 +3081,11 @@ BlobChild::CommonInit(const ChildBlobConstructorParams& aParams) 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; } @@ -3114,11 +3120,9 @@ BlobChild::CommonInit(const ChildBlobConstructorParams& aParams) 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; @@ -3588,14 +3592,6 @@ BlobChild::DeallocPBlobStreamChild(PBlobStreamChild* aActor) return true; } -bool -BlobChild::RecvCreatedFromKnownBlob() -{ - // Releasing the other blob now that this blob is fully created. - mRemoteBlobImpl->NullifyDifferentProcessBlobImpl(); - return true; -} - /******************************************************************************* * BlobParent ******************************************************************************/ diff --git a/dom/ipc/BlobChild.h b/dom/ipc/BlobChild.h index 35853f307df..1b5627378bc 100644 --- a/dom/ipc/BlobChild.h +++ b/dom/ipc/BlobChild.h @@ -220,9 +220,6 @@ private: virtual bool DeallocPBlobStreamChild(PBlobStreamChild* aActor) override; - - virtual bool - RecvCreatedFromKnownBlob() override; }; // Only let ContentChild call BlobChild::Startup() and ensure that diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 4b93977a224..fa65e883fab 100755 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -3515,18 +3515,6 @@ 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() { diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 5c3595743da..a334c3bc95a 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -648,9 +648,6 @@ private: 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, diff --git a/dom/ipc/PBlob.ipdl b/dom/ipc/PBlob.ipdl index 09b78b16308..b2e57e92ce9 100644 --- a/dom/ipc/PBlob.ipdl +++ b/dom/ipc/PBlob.ipdl @@ -45,11 +45,6 @@ parent: // 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 diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp index 48e6d6334e7..7a427b9f374 100644 --- a/ipc/glue/BackgroundParentImpl.cpp +++ b/ipc/glue/BackgroundParentImpl.cpp @@ -13,7 +13,6 @@ #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" @@ -244,18 +243,6 @@ BackgroundParentImpl::DeallocPBlobParent(PBlobParent* 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) diff --git a/ipc/glue/BackgroundParentImpl.h b/ipc/glue/BackgroundParentImpl.h index 2dc5b2953d2..1142aa85649 100644 --- a/ipc/glue/BackgroundParentImpl.h +++ b/ipc/glue/BackgroundParentImpl.h @@ -64,10 +64,6 @@ protected: virtual bool DeallocPBlobParent(PBlobParent* aActor) override; - virtual bool - RecvPBlobConstructor(PBlobParent* aActor, - const BlobConstructorParams& params) override; - virtual PFileDescriptorSetParent* AllocPFileDescriptorSetParent(const FileDescriptor& aFileDescriptor) override;