Bug 1535397 - Part 2 - use native Maybe syntax in place of IPCFileUnion in IDPL; r=baku
authorAlex Gaynor <agaynor@mozilla.com>
Fri, 15 Mar 2019 17:09:59 +0000
changeset 464436 b9479ab9a8f3
parent 464435 cd11bf45d948
child 464437 4d2c953008cd
push id35716
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:42:17 +0000
treeherdermozilla-central@8ee97c045359 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1535397
milestone67.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 1535397 - Part 2 - use native Maybe syntax in place of IPCFileUnion in IDPL; r=baku Differential Revision: https://phabricator.services.mozilla.com/D23559
dom/file/ipc/IPCBlob.ipdlh
dom/file/ipc/IPCBlobUtils.cpp
--- a/dom/file/ipc/IPCBlob.ipdlh
+++ b/dom/file/ipc/IPCBlob.ipdlh
@@ -25,26 +25,16 @@ struct IPCFile
   int64_t lastModified;
   nsString DOMPath;
   nsString fullPath;
 
   // Useful for Entries API.
   bool isDirectory;
 };
 
-// Union for blob vs file.
-union IPCFileUnion
-{
-  // For Blob.
-  void_t;
-
-  // For File.
-  IPCFile;
-};
-
 union IPCBlobStream
 {
   // Parent to Child: The child will receive a IPCBlobInputStream. Nothing
   // can be done with it except retrieving the size.
   PIPCBlobInputStream;
 
   // Child to Parent: Normal serialization.
   IPCStream;
@@ -53,16 +43,17 @@ union IPCBlobStream
 struct IPCBlob
 {
   nsString type;
   uint64_t size;
   nsString blobImplType;
 
   IPCBlobStream inputStream;
 
-  IPCFileUnion file;
+  // Nothing is for Blob
+  IPCFile? file;
 
   // This ID is used only by indexedDB tests.
   int64_t fileId;
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/file/ipc/IPCBlobUtils.cpp
+++ b/dom/file/ipc/IPCBlobUtils.cpp
@@ -52,21 +52,21 @@ already_AddRefed<BlobImpl> Deserialize(c
       MOZ_CRASH("Unknown type.");
       break;
   }
 
   MOZ_ASSERT(inputStream);
 
   RefPtr<StreamBlobImpl> blobImpl;
 
-  if (aIPCBlob.file().type() == IPCFileUnion::Tvoid_t) {
+  if (aIPCBlob.file().isNothing()) {
     blobImpl = StreamBlobImpl::Create(inputStream.forget(), aIPCBlob.type(),
                                       aIPCBlob.size(), aIPCBlob.blobImplType());
   } else {
-    const IPCFile& file = aIPCBlob.file().get_IPCFile();
+    const IPCFile& file = aIPCBlob.file().ref();
     blobImpl = StreamBlobImpl::Create(inputStream.forget(), file.name(),
                                       aIPCBlob.type(), file.lastModified(),
                                       aIPCBlob.size(), aIPCBlob.blobImplType());
     blobImpl->SetDOMPath(file.DOMPath());
     blobImpl->SetFullPath(file.fullPath());
     blobImpl->SetIsDirectory(file.isDirectory());
   }
 
@@ -184,17 +184,17 @@ nsresult SerializeInternal(BlobImpl* aBl
 
   ErrorResult rv;
   aIPCBlob.size() = aBlobImpl->GetSize(rv);
   if (NS_WARN_IF(rv.Failed())) {
     return rv.StealNSResult();
   }
 
   if (!aBlobImpl->IsFile()) {
-    aIPCBlob.file() = void_t();
+    aIPCBlob.file() = Nothing();
   } else {
     IPCFile file;
 
     aBlobImpl->GetName(value);
     file.name() = value;
 
     file.lastModified() = aBlobImpl->GetLastModified(rv) * PR_USEC_PER_MSEC;
     if (NS_WARN_IF(rv.Failed())) {
@@ -207,17 +207,17 @@ nsresult SerializeInternal(BlobImpl* aBl
     aBlobImpl->GetMozFullPathInternal(value, rv);
     if (NS_WARN_IF(rv.Failed())) {
       return rv.StealNSResult();
     }
     file.fullPath() = value;
 
     file.isDirectory() = aBlobImpl->IsDirectory();
 
-    aIPCBlob.file() = file;
+    aIPCBlob.file() = Some(file);
   }
 
   aIPCBlob.fileId() = aBlobImpl->GetFileId();
 
   nsCOMPtr<nsIInputStream> inputStream;
   aBlobImpl->CreateInputStream(getter_AddRefs(inputStream), rv);
   if (NS_WARN_IF(rv.Failed())) {
     return rv.StealNSResult();