Bug 1535397 - Part 4 - use native Maybe syntax in place of NullableVersion in IDPL; r=baku
authorAlex Gaynor <agaynor@mozilla.com>
Fri, 15 Mar 2019 17:10:29 +0000
changeset 464438 533d85bbc15d
parent 464437 4d2c953008cd
child 464439 11017d53d6bd
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 4 - use native Maybe syntax in place of NullableVersion in IDPL; r=baku Differential Revision: https://phabricator.services.mozilla.com/D23561
dom/indexedDB/ActorsChild.cpp
dom/indexedDB/ActorsChild.h
dom/indexedDB/ActorsParent.cpp
dom/indexedDB/PBackgroundIDBDatabase.ipdl
--- a/dom/indexedDB/ActorsChild.cpp
+++ b/dom/indexedDB/ActorsChild.cpp
@@ -2048,17 +2048,17 @@ bool BackgroundDatabaseChild::DeallocPBa
     PBackgroundMutableFileChild* aActor) {
   MOZ_ASSERT(aActor);
 
   delete static_cast<BackgroundMutableFileChild*>(aActor);
   return true;
 }
 
 mozilla::ipc::IPCResult BackgroundDatabaseChild::RecvVersionChange(
-    const uint64_t& aOldVersion, const NullableVersion& aNewVersion) {
+    const uint64_t& aOldVersion, const Maybe<uint64_t>& aNewVersion) {
   AssertIsOnOwningThread();
 
   MaybeCollectGarbageOnIPCMessage();
 
   if (!mDatabase || mDatabase->IsClosed()) {
     return IPC_OK();
   }
 
@@ -2087,31 +2087,24 @@ mozilla::ipc::IPCResult BackgroundDataba
     }
   }
 
   // Otherwise fire a versionchange event.
   const nsDependentString type(kVersionChangeEventType);
 
   RefPtr<Event> versionChangeEvent;
 
-  switch (aNewVersion.type()) {
-    case NullableVersion::Tnull_t:
-      versionChangeEvent =
-          IDBVersionChangeEvent::Create(kungFuDeathGrip, type, aOldVersion);
-      MOZ_ASSERT(versionChangeEvent);
-      break;
-
-    case NullableVersion::Tuint64_t:
-      versionChangeEvent = IDBVersionChangeEvent::Create(
-          kungFuDeathGrip, type, aOldVersion, aNewVersion.get_uint64_t());
-      MOZ_ASSERT(versionChangeEvent);
-      break;
-
-    default:
-      MOZ_CRASH("Should never get here!");
+  if (aNewVersion.isNothing()) {
+    versionChangeEvent =
+        IDBVersionChangeEvent::Create(kungFuDeathGrip, type, aOldVersion);
+    MOZ_ASSERT(versionChangeEvent);
+  } else {
+    versionChangeEvent = IDBVersionChangeEvent::Create(
+        kungFuDeathGrip, type, aOldVersion, aNewVersion.value());
+    MOZ_ASSERT(versionChangeEvent);
   }
 
   IDB_LOG_MARK("IndexedDB %s: Child : Firing \"versionchange\" event",
                "IndexedDB %s: C: IDBDatabase \"versionchange\" event",
                IDB_LOG_ID_STRING());
 
   IgnoredErrorResult rv;
   kungFuDeathGrip->DispatchEvent(*versionChangeEvent, rv);
--- a/dom/indexedDB/ActorsChild.h
+++ b/dom/indexedDB/ActorsChild.h
@@ -346,17 +346,17 @@ class BackgroundDatabaseChild final : pu
 
   virtual PBackgroundMutableFileChild* AllocPBackgroundMutableFileChild(
       const nsString& aName, const nsString& aType) override;
 
   virtual bool DeallocPBackgroundMutableFileChild(
       PBackgroundMutableFileChild* aActor) override;
 
   virtual mozilla::ipc::IPCResult RecvVersionChange(
-      const uint64_t& aOldVersion, const NullableVersion& aNewVersion) override;
+      const uint64_t& aOldVersion, const Maybe<uint64_t>& aNewVersion) override;
 
   virtual mozilla::ipc::IPCResult RecvInvalidate() override;
 
   virtual mozilla::ipc::IPCResult RecvCloseAfterInvalidationComplete() override;
 
   bool SendDeleteMe() = delete;
 };
 
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -6595,17 +6595,17 @@ class FactoryOp : public DatabaseOperati
 
   void CleanupMetadata();
 
   void FinishSendResults();
 
   nsresult SendVersionChangeMessages(DatabaseActorInfo* aDatabaseActorInfo,
                                      Database* aOpeningDatabase,
                                      uint64_t aOldVersion,
-                                     const NullableVersion& aNewVersion);
+                                     const Maybe<uint64_t>& aNewVersion);
 
   // Methods that subclasses must implement.
   virtual nsresult DatabaseOpen() = 0;
 
   virtual nsresult DoDatabaseWork() = 0;
 
   virtual nsresult BeginVersionChange() = 0;
 
@@ -19389,17 +19389,17 @@ nsresult FactoryOp::CheckPermission(
   }
 
   *aPermission = permission;
   return NS_OK;
 }
 
 nsresult FactoryOp::SendVersionChangeMessages(
     DatabaseActorInfo* aDatabaseActorInfo, Database* aOpeningDatabase,
-    uint64_t aOldVersion, const NullableVersion& aNewVersion) {
+    uint64_t aOldVersion, const Maybe<uint64_t>& aNewVersion) {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aDatabaseActorInfo);
   MOZ_ASSERT(mState == State::BeginVersionChange);
   MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
   MOZ_ASSERT(!IsActorDestroyed());
 
   const uint32_t expectedCount = mDeleting ? 0 : 1;
   const uint32_t liveCount = aDatabaseActorInfo->mLiveDatabases.Length();
@@ -20421,17 +20421,17 @@ nsresult OpenDatabaseOp::BeginVersionCha
 
   if (NS_WARN_IF(!transaction->CopyDatabaseMetadata())) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   MOZ_ASSERT(info->mMetadata != mMetadata);
   mMetadata = info->mMetadata;
 
-  NullableVersion newVersion = mRequestedVersion;
+  Maybe<uint64_t> newVersion = Some(mRequestedVersion);
 
   nsresult rv = SendVersionChangeMessages(
       info, mDatabase, mMetadata->mCommonMetadata.version(), newVersion);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   mVersionChangeTransaction.swap(transaction);
@@ -21180,20 +21180,18 @@ nsresult DeleteDatabaseOp::BeginVersionC
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   DatabaseActorInfo* info;
   if (gLiveDatabaseHashtable->Get(mDatabaseId, &info)) {
     MOZ_ASSERT(!info->mWaitingFactoryOp);
 
-    NullableVersion newVersion = null_t();
-
     nsresult rv =
-        SendVersionChangeMessages(info, nullptr, mPreviousVersion, newVersion);
+        SendVersionChangeMessages(info, nullptr, mPreviousVersion, Nothing());
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     if (!mMaybeBlockedDatabases.IsEmpty()) {
       info->mWaitingFactoryOp = this;
 
       mState = State::WaitingForOtherDatabasesToClose;
--- a/dom/indexedDB/PBackgroundIDBDatabase.ipdl
+++ b/dom/indexedDB/PBackgroundIDBDatabase.ipdl
@@ -35,22 +35,16 @@ struct CreateFileParams
   nsString type;
 };
 
 union DatabaseRequestParams
 {
   CreateFileParams;
 };
 
-union NullableVersion
-{
-  null_t;
-  uint64_t;
-};
-
 sync protocol PBackgroundIDBDatabase
 {
   manager PBackgroundIDBFactory;
 
   manages PBackgroundIDBDatabaseFile;
   manages PBackgroundIDBDatabaseRequest;
   manages PBackgroundIDBTransaction;
   manages PBackgroundIDBVersionChangeTransaction;
@@ -67,17 +61,17 @@ parent:
 
   async PBackgroundIDBDatabaseRequest(DatabaseRequestParams params);
 
   async PBackgroundIDBTransaction(nsString[] objectStoreNames, Mode mode);
 
 child:
   async __delete__();
 
-  async VersionChange(uint64_t oldVersion, NullableVersion newVersion);
+  async VersionChange(uint64_t oldVersion, uint64_t? newVersion);
 
   async Invalidate();
 
   async CloseAfterInvalidationComplete();
 
   async PBackgroundIDBVersionChangeTransaction(uint64_t currentVersion,
                                                uint64_t requestedVersion,
                                                int64_t nextObjectStoreId,