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 522325 b9479ab9a8f378b5d46fd1e212b5f6be16565264
parent 522324 cd11bf45d948ab603bfd0eecada05b8854e93e0a
child 522326 4d2c953008cd91e6409c9c1abdc921d7d1cc99c4
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [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();