From 0958279585a7eac66cb11e9fac083e8f79b72382 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Thu, 14 Jul 2016 09:04:52 +0200 Subject: [PATCH] Bug 1186932 - Implement support for form submission of a picked directory - part 7 - path in RemoteBlobImpl, r=smaug --- dom/ipc/Blob.cpp | 42 ++++++++++++++++++++++++++++++++++-------- dom/ipc/DOMTypes.ipdlh | 1 + 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/dom/ipc/Blob.cpp b/dom/ipc/Blob.cpp index 7bd1d221e268..cfb0c16460f7 100644 --- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -906,6 +906,11 @@ CreateBlobImpl(const ParentBlobConstructorParams& aParams, return nullptr; } + if (NS_WARN_IF(!params.path().IsEmpty())) { + ASSERT_UNLESS_FUZZING(); + return nullptr; + } + metadata.mContentType = params.contentType(); metadata.mName = params.name(); metadata.mLength = params.length(); @@ -1713,6 +1718,7 @@ public: BlobImpl* aRemoteBlobImpl, const nsAString& aName, const nsAString& aContentType, + const nsAString& aPath, uint64_t aLength, int64_t aModDate, bool aIsSameProcessBlob); @@ -2024,12 +2030,15 @@ RemoteBlobImpl::RemoteBlobImpl(BlobChild* aActor, BlobImpl* aRemoteBlobImpl, const nsAString& aName, const nsAString& aContentType, + const nsAString& aPath, uint64_t aLength, int64_t aModDate, bool aIsSameProcessBlob) : BlobImplBase(aName, aContentType, aLength, aModDate) , mIsSlice(false) { + SetPath(aPath); + if (aIsSameProcessBlob) { MOZ_ASSERT(aRemoteBlobImpl); mSameProcessBlobImpl = aRemoteBlobImpl; @@ -2934,14 +2943,18 @@ BlobChild::CommonInit(BlobChild* aOther, BlobImpl* aBlobImpl) RemoteBlobImpl* remoteBlob = nullptr; if (otherImpl->IsFile()) { - nsString name; + nsAutoString name; otherImpl->GetName(name); + nsAutoString path; + otherImpl->GetPath(path); + int64_t modDate = otherImpl->GetLastModified(rv); MOZ_ASSERT(!rv.Failed()); - remoteBlob = new RemoteBlobImpl(this, otherImpl, name, contentType, length, - modDate, false /* SameProcessBlobImpl */); + remoteBlob = + new RemoteBlobImpl(this, otherImpl, name, contentType, path, + length, modDate, false /* SameProcessBlobImpl */); } else { remoteBlob = new RemoteBlobImpl(this, otherImpl, contentType, length, false /* SameProcessBlobImpl */); @@ -2991,6 +3004,7 @@ BlobChild::CommonInit(const ChildBlobConstructorParams& aParams) nullptr, params.name(), params.contentType(), + params.path(), params.length(), params.modDate(), false /* SameProcessBlobImpl */); @@ -3015,9 +3029,12 @@ BlobChild::CommonInit(const ChildBlobConstructorParams& aParams) blobImpl->GetType(contentType); if (blobImpl->IsFile()) { - nsString name; + nsAutoString name; blobImpl->GetName(name); + nsAutoString path; + blobImpl->GetPath(path); + int64_t lastModifiedDate = blobImpl->GetLastModified(rv); MOZ_ASSERT(!rv.Failed()); @@ -3026,6 +3043,7 @@ BlobChild::CommonInit(const ChildBlobConstructorParams& aParams) blobImpl, name, contentType, + path, size, lastModifiedDate, true /* SameProcessBlobImpl */); @@ -3201,14 +3219,18 @@ BlobChild::GetOrCreateFromImpl(ChildManagerType* aManager, MOZ_ASSERT(!rv.Failed()); if (aBlobImpl->IsFile()) { - nsString name; + nsAutoString name; aBlobImpl->GetName(name); + nsAutoString path; + aBlobImpl->GetPath(path); + int64_t modDate = aBlobImpl->GetLastModified(rv); MOZ_ASSERT(!rv.Failed()); blobParams = - FileBlobConstructorParams(name, contentType, length, modDate, blobData); + FileBlobConstructorParams(name, contentType, path, length, modDate, + blobData); } else { blobParams = NormalBlobConstructorParams(contentType, length, blobData); } @@ -3392,6 +3414,7 @@ BlobChild::SetMysteryBlobInfo(const nsString& aName, FileBlobConstructorParams params(aName, aContentType, + EmptyString(), aLength, aLastModifiedDate, void_t() /* optionalBlobData */); @@ -3748,14 +3771,17 @@ BlobParent::GetOrCreateFromImpl(ParentManagerType* aManager, MOZ_ASSERT(!rv.Failed()); if (aBlobImpl->IsFile()) { - nsString name; + nsAutoString name; aBlobImpl->GetName(name); + nsAutoString path; + aBlobImpl->GetPath(path); + int64_t modDate = aBlobImpl->GetLastModified(rv); MOZ_ASSERT(!rv.Failed()); blobParams = - FileBlobConstructorParams(name, contentType, length, modDate, + FileBlobConstructorParams(name, contentType, path, length, modDate, void_t()); } else { blobParams = NormalBlobConstructorParams(contentType, length, void_t()); diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh index 5bd5d44e94f3..8615fa142c58 100644 --- a/dom/ipc/DOMTypes.ipdlh +++ b/dom/ipc/DOMTypes.ipdlh @@ -71,6 +71,7 @@ struct FileBlobConstructorParams { nsString name; nsString contentType; + nsString path; uint64_t length; int64_t modDate;