Bug 1535397 - Part 3 - use native Maybe syntax in place of FileRequestSize and FileRequestLastModified in IDPL; r=baku
authorAlex Gaynor <agaynor@mozilla.com>
Fri, 15 Mar 2019 17:10:13 +0000
changeset 464643 4d2c953008cd91e6409c9c1abdc921d7d1cc99c4
parent 464642 b9479ab9a8f378b5d46fd1e212b5f6be16565264
child 464644 533d85bbc15d7b58b523f337e8111ee013a720fa
push id112465
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:50:10 +0000
treeherdermozilla-inbound@e0861be8d6c0 [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 3 - use native Maybe syntax in place of FileRequestSize and FileRequestLastModified in IDPL; r=baku Differential Revision: https://phabricator.services.mozilla.com/D23560
dom/filehandle/ActorsParent.cpp
dom/filehandle/PBackgroundFileRequest.ipdl
dom/indexedDB/ActorsChild.cpp
--- a/dom/filehandle/ActorsParent.cpp
+++ b/dom/filehandle/ActorsParent.cpp
@@ -1983,31 +1983,31 @@ nsresult GetMetadataOp::DoFileWork(FileH
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     if (NS_WARN_IF(size < 0)) {
       return NS_ERROR_FAILURE;
     }
 
-    mMetadata.size() = uint64_t(size);
+    mMetadata.size() = Some(uint64_t(size));
   } else {
-    mMetadata.size() = void_t();
+    mMetadata.size() = Nothing();
   }
 
   if (mParams.lastModified()) {
     int64_t lastModified;
     rv = metadata->GetLastModified(&lastModified);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    mMetadata.lastModified() = lastModified;
+    mMetadata.lastModified() = Some(lastModified);
   } else {
-    mMetadata.lastModified() = void_t();
+    mMetadata.lastModified() = Nothing();
   }
 
   return NS_OK;
 }
 
 void GetMetadataOp::GetResponse(FileRequestResponse& aResponse) {
   AssertIsOnOwningThread();
 
--- a/dom/filehandle/PBackgroundFileRequest.ipdl
+++ b/dom/filehandle/PBackgroundFileRequest.ipdl
@@ -6,32 +6,20 @@ include protocol PBackgroundFileHandle;
 include protocol PPendingIPCBlob;
 
 using struct mozilla::void_t
   from "ipc/IPCMessageUtils.h";
 
 namespace mozilla {
 namespace dom {
 
-union FileRequestSize
-{
-  void_t;
-  uint64_t;
-};
-
-union FileRequestLastModified
-{
-  void_t;
-  int64_t;
-};
-
 struct FileRequestMetadata
 {
-  FileRequestSize size;
-  FileRequestLastModified lastModified;
+  uint64_t? size;
+  int64_t? lastModified;
 };
 
 struct FileRequestGetMetadataResponse
 {
   FileRequestMetadata metadata;
 };
 
 struct FileRequestReadResponse
--- a/dom/indexedDB/ActorsChild.cpp
+++ b/dom/indexedDB/ActorsChild.cpp
@@ -1219,34 +1219,29 @@ class MOZ_STACK_CLASS FileHandleResultHe
 
   nsresult GetResult(JSContext* aCx, const FileRequestMetadata* aMetadata,
                      JS::MutableHandle<JS::Value> aResult) {
     JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
     if (NS_WARN_IF(!obj)) {
       return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
     }
 
-    const FileRequestSize& size = aMetadata->size();
-    if (size.type() != FileRequestSize::Tvoid_t) {
-      MOZ_ASSERT(size.type() == FileRequestSize::Tuint64_t);
-
-      JS::Rooted<JS::Value> number(aCx, JS_NumberValue(size.get_uint64_t()));
+    const Maybe<uint64_t>& size = aMetadata->size();
+    if (size.isSome()) {
+      JS::Rooted<JS::Value> number(aCx, JS_NumberValue(size.value()));
 
       if (NS_WARN_IF(!JS_DefineProperty(aCx, obj, "size", number, 0))) {
         return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
       }
     }
 
-    const FileRequestLastModified& lastModified = aMetadata->lastModified();
-    if (lastModified.type() != FileRequestLastModified::Tvoid_t) {
-      MOZ_ASSERT(lastModified.type() == FileRequestLastModified::Tint64_t);
-
+    const Maybe<int64_t>& lastModified = aMetadata->lastModified();
+    if (lastModified.isSome()) {
       JS::Rooted<JSObject*> date(
-          aCx,
-          JS::NewDateObject(aCx, JS::TimeClip(lastModified.get_int64_t())));
+          aCx, JS::NewDateObject(aCx, JS::TimeClip(lastModified.value())));
       if (NS_WARN_IF(!date)) {
         return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
       }
 
       if (NS_WARN_IF(!JS_DefineProperty(aCx, obj, "lastModified", date, 0))) {
         return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
       }
     }
@@ -1260,25 +1255,25 @@ already_AddRefed<File> ConvertActorToFil
     IDBFileHandle* aFileHandle, const FileRequestGetFileResponse& aResponse) {
   auto* actor = static_cast<PendingIPCBlobChild*>(aResponse.fileChild());
 
   IDBMutableFile* mutableFile = aFileHandle->GetMutableFile();
   MOZ_ASSERT(mutableFile);
 
   const FileRequestMetadata& metadata = aResponse.metadata();
 
-  const FileRequestSize& size = metadata.size();
-  MOZ_ASSERT(size.type() == FileRequestSize::Tuint64_t);
-
-  const FileRequestLastModified& lastModified = metadata.lastModified();
-  MOZ_ASSERT(lastModified.type() == FileRequestLastModified::Tint64_t);
+  const Maybe<uint64_t>& size = metadata.size();
+  MOZ_ASSERT(size.isSome());
+
+  const Maybe<int64_t>& lastModified = metadata.lastModified();
+  MOZ_ASSERT(lastModified.isSome());
 
   RefPtr<BlobImpl> blobImpl = actor->SetPendingInfoAndDeleteActor(
-      mutableFile->Name(), mutableFile->Type(), size.get_uint64_t(),
-      lastModified.get_int64_t());
+      mutableFile->Name(), mutableFile->Type(), size.value(),
+      lastModified.value());
   MOZ_ASSERT(blobImpl);
 
   RefPtr<BlobImpl> blobImplSnapshot =
       new BlobImplSnapshot(blobImpl, static_cast<IDBFileHandle*>(aFileHandle));
 
   RefPtr<File> file = File::Create(mutableFile->GetOwner(), blobImplSnapshot);
   return file.forget();
 }