From 44a1314868763561f6665ef70af907b107872a7d Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Mon, 24 Apr 2017 12:16:49 +0200 Subject: [PATCH] Bug 1358111 - Use IPCBlob in Entries API - part 1 - GetFilesHelper, r=smaug --- dom/filesystem/GetFilesHelper.cpp | 14 +++++++++----- dom/ipc/ContentChild.cpp | 9 +++++---- dom/ipc/PContent.ipdl | 3 ++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dom/filesystem/GetFilesHelper.cpp b/dom/filesystem/GetFilesHelper.cpp index 8bd1997c308d..80462834cd5a 100644 --- a/dom/filesystem/GetFilesHelper.cpp +++ b/dom/filesystem/GetFilesHelper.cpp @@ -8,6 +8,8 @@ #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/FileBlobImpl.h" +#include "mozilla/dom/IPCBlobUtils.h" +#include "mozilla/ipc/IPCStreamUtils.h" #include "FileSystemUtils.h" #include "nsProxyRelease.h" @@ -585,13 +587,15 @@ public: } GetFilesResponseSuccess success; - nsTArray& blobsParent = success.blobsParent(); - blobsParent.SetLength(aFiles.Length()); + + nsTArray& ipcBlobs = success.blobs(); + ipcBlobs.SetLength(aFiles.Length()); for (uint32_t i = 0; i < aFiles.Length(); ++i) { - blobsParent[i] = - mParent->mContentParent->GetOrCreateActorForBlob(aFiles[i]); - if (!blobsParent[i]) { + nsresult rv = IPCBlobUtils::Serialize(aFiles[i]->Impl(), + mParent->mContentParent, + ipcBlobs[i]); + if (NS_WARN_IF(NS_FAILED(rv))) { mParent->mContentParent->SendGetFilesResponseAndForget(mParent->mUUID, GetFilesResponseFailure(NS_ERROR_OUT_OF_MEMORY)); return; diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 75bf0b810493..e50d6967e19b 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -31,6 +31,7 @@ #include "mozilla/dom/FileCreatorHelper.h" #include "mozilla/dom/FlyWebPublishedServerIPC.h" #include "mozilla/dom/GetFilesHelper.h" +#include "mozilla/dom/IPCBlobUtils.h" #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/dom/ProcessGlobal.h" #include "mozilla/dom/PushNotifier.h" @@ -3152,12 +3153,12 @@ ContentChild::RecvGetFilesResponse(const nsID& aUUID, } else { MOZ_ASSERT(aResult.type() == GetFilesResponseResult::TGetFilesResponseSuccess); - const nsTArray& blobs = - aResult.get_GetFilesResponseSuccess().blobsChild(); + const nsTArray& ipcBlobs = + aResult.get_GetFilesResponseSuccess().blobs(); bool succeeded = true; - for (uint32_t i = 0; succeeded && i < blobs.Length(); ++i) { - RefPtr impl = static_cast(blobs[i])->GetBlobImpl(); + for (uint32_t i = 0; succeeded && i < ipcBlobs.Length(); ++i) { + RefPtr impl = IPCBlobUtils::Deserialize(ipcBlobs[i]); succeeded = child->AppendBlobImpl(impl); } diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 045694b7f7cd..9a6266dbf202 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -47,6 +47,7 @@ include protocol PVideoDecoderManager; include protocol PFlyWebPublishedServer; include DOMTypes; include JavaScriptTypes; +include IPCBlob; include IPCStream; include PTabContext; include URIParams; @@ -195,7 +196,7 @@ struct AndroidSystemInfo struct GetFilesResponseSuccess { - PBlob[] blobs; + IPCBlob[] blobs; }; struct GetFilesResponseFailure