Bug 1358113 - Use IPCBlob in File.createFromNsIFile/createFromFileName, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 24 Apr 2017 12:16:50 +0200
changeset 354810 049673ad3893929604cc5d38d3739de7806c4695
parent 354809 2ef7ae7a605f0ee74f04d92fb6fd8d8a122a30fa
child 354811 2629873b5fdc01cec28a97ed29cd9ebb8dbc3180
push id31714
push userkwierso@gmail.com
push dateTue, 25 Apr 2017 20:53:09 +0000
treeherdermozilla-central@2c497462f25e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1358113
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1358113 - Use IPCBlob in File.createFromNsIFile/createFromFileName, r=smaug
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/PContent.ipdl
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -3300,21 +3300,18 @@ ContentChild::RecvFileCreationResponse(c
   }
 
   if (aResult.type() == FileCreationResult::TFileCreationErrorResult) {
     helper->ResponseReceived(nullptr,
                              aResult.get_FileCreationErrorResult().errorCode());
   } else {
     MOZ_ASSERT(aResult.type() == FileCreationResult::TFileCreationSuccessResult);
 
-    PBlobChild* blobChild =
-      aResult.get_FileCreationSuccessResult().blobChild();
-    MOZ_ASSERT(blobChild);
-
-    RefPtr<BlobImpl> impl = static_cast<BlobChild*>(blobChild)->GetBlobImpl();
+    RefPtr<BlobImpl> impl =
+      IPCBlobUtils::Deserialize(aResult.get_FileCreationSuccessResult().blob());
     helper->ResponseReceived(impl, NS_OK);
   }
 
   mFileCreationPending.Remove(aUUID);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -41,16 +41,17 @@
 #include "mozilla/DataStorage.h"
 #include "mozilla/devtools/HeapSnapshotTempFileHelperParent.h"
 #include "mozilla/docshell/OfflineCacheUpdateParent.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FileCreatorHelper.h"
 #include "mozilla/dom/FileSystemSecurity.h"
+#include "mozilla/dom/IPCBlobUtils.h"
 #include "mozilla/dom/ExternalHelperAppParent.h"
 #include "mozilla/dom/GetFilesHelper.h"
 #include "mozilla/dom/GeolocationBinding.h"
 #include "mozilla/dom/MemoryReportRequest.h"
 #include "mozilla/dom/Notification.h"
 #include "mozilla/dom/PContentBridgeParent.h"
 #include "mozilla/dom/PContentPermissionRequestParent.h"
 #include "mozilla/dom/PCycleCollectWithLogsParent.h"
@@ -5312,20 +5313,24 @@ ContentParent::RecvFileCreationRequest(c
       return IPC_FAIL_NO_REASON(this);
     }
 
     return IPC_OK();
   }
 
   MOZ_ASSERT(blobImpl);
 
-  BlobParent* blobParent = BlobParent::GetOrCreate(this, blobImpl);
-  if (NS_WARN_IF(!blobParent)) {
-    return IPC_FAIL_NO_REASON(this);
-  }
-
-  if (!SendFileCreationResponse(aID,
-                                FileCreationSuccessResult(blobParent, nullptr))) {
+  IPCBlob ipcBlob;
+  rv = IPCBlobUtils::Serialize(blobImpl, this, ipcBlob);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    if (!SendFileCreationResponse(aID, FileCreationErrorResult(rv))) {
+      return IPC_FAIL_NO_REASON(this);
+    }
+
+    return IPC_OK();
+  }
+
+  if (!SendFileCreationResponse(aID, FileCreationSuccessResult(ipcBlob))) {
     return IPC_FAIL_NO_REASON(this);
   }
 
   return IPC_OK();
 }
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -207,17 +207,17 @@ struct GetFilesResponseFailure
 union GetFilesResponseResult
 {
   GetFilesResponseSuccess;
   GetFilesResponseFailure;
 };
 
 struct FileCreationSuccessResult
 {
-  PBlob blob;
+  IPCBlob blob;
 };
 
 struct FileCreationErrorResult
 {
   nsresult errorCode;
 };
 
 union FileCreationResult