Bug 1328517 - Part 2: Add Assertion to Each ActorEventTarget. r=janv
authorBevis Tseng <btseng@mozilla.com>
Fri, 10 Feb 2017 15:13:45 +0800
changeset 345285 479e6d9edfb7294b207ad511efa28ce9c538725f
parent 345284 26fd555ab1bbe228799d8de80feb0679e9f68adc
child 345286 f73f900fab1c6e320786647327204cce7ba31bcb
push id31436
push userkwierso@gmail.com
push dateThu, 02 Mar 2017 01:18:52 +0000
treeherdermozilla-central@e91de6fb2b3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs1328517
milestone54.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 1328517 - Part 2: Add Assertion to Each ActorEventTarget. r=janv MozReview-Commit-ID: DDQ0ytBiwm3
dom/indexedDB/ActorsChild.cpp
dom/indexedDB/ActorsChild.h
dom/indexedDB/IDBDatabase.cpp
dom/indexedDB/IDBFactory.cpp
dom/indexedDB/IDBTransaction.cpp
--- a/dom/indexedDB/ActorsChild.cpp
+++ b/dom/indexedDB/ActorsChild.cpp
@@ -1103,16 +1103,17 @@ private:
 
     TabChild* tabChild = TabChild::GetFrom(window);
     MOZ_ASSERT(tabChild);
 
     IPC::Principal ipcPrincipal(principal);
 
     auto* actor = new WorkerPermissionRequestChildProcessActor(this);
     tabChild->SetEventTargetForActor(actor, wp->MainThreadEventTarget());
+    MOZ_ASSERT(actor->GetActorEventTarget());
     tabChild->SendPIndexedDBPermissionRequestConstructor(actor, ipcPrincipal);
     return false;
   }
 
 private:
   WorkerPrivate* mWorkerPrivate;
   BackgroundFactoryRequestChild* mActor;
   RefPtr<IDBFactory> mFactory;
@@ -1398,16 +1399,30 @@ BackgroundFactoryChild::DeallocPBackgrou
                                             PBackgroundIDBDatabaseChild* aActor)
 {
   MOZ_ASSERT(aActor);
 
   delete static_cast<BackgroundDatabaseChild*>(aActor);
   return true;
 }
 
+mozilla::ipc::IPCResult
+BackgroundFactoryChild::RecvPBackgroundIDBDatabaseConstructor(
+                                    PBackgroundIDBDatabaseChild* aActor,
+                                    const DatabaseSpec& aSpec,
+                                    PBackgroundIDBFactoryRequestChild* aRequest)
+{
+  AssertIsOnOwningThread();
+  MOZ_ASSERT(aActor);
+  MOZ_ASSERT(aActor->GetActorEventTarget(),
+    "The event target shall be inherited from its manager actor.");
+
+  return IPC_OK();
+}
+
 /*******************************************************************************
  * BackgroundFactoryRequestChild
  ******************************************************************************/
 
 BackgroundFactoryRequestChild::BackgroundFactoryRequestChild(
                                                IDBFactory* aFactory,
                                                IDBOpenDBRequest* aOpenRequest,
                                                bool aIsDeleteOp,
@@ -1629,17 +1644,17 @@ BackgroundFactoryRequestChild::RecvPermi
   RefPtr<TabChild> tabChild = mFactory->GetTabChild();
   MOZ_ASSERT(tabChild);
 
   IPC::Principal ipcPrincipal(principal);
 
   auto* actor = new PermissionRequestChildProcessActor(this, mFactory);
 
   tabChild->SetEventTargetForActor(actor, this->GetActorEventTarget());
-
+  MOZ_ASSERT(actor->GetActorEventTarget());
   tabChild->SendPIndexedDBPermissionRequestConstructor(actor, ipcPrincipal);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 BackgroundFactoryRequestChild::RecvBlocked(const uint64_t& aCurrentVersion)
 {
@@ -1853,16 +1868,18 @@ BackgroundDatabaseChild::RecvPBackground
                             PBackgroundIDBVersionChangeTransactionChild* aActor,
                             const uint64_t& aCurrentVersion,
                             const uint64_t& aRequestedVersion,
                             const int64_t& aNextObjectStoreId,
                             const int64_t& aNextIndexId)
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aActor);
+  MOZ_ASSERT(aActor->GetActorEventTarget(),
+    "The event target shall be inherited from its manager actor.");
   MOZ_ASSERT(mOpenRequestActor);
 
   MaybeCollectGarbageOnIPCMessage();
 
   EnsureDOMObject();
 
   auto* actor = static_cast<BackgroundVersionChangeTransactionChild*>(aActor);
 
--- a/dom/indexedDB/ActorsChild.h
+++ b/dom/indexedDB/ActorsChild.h
@@ -210,16 +210,23 @@ private:
   AllocPBackgroundIDBDatabaseChild(const DatabaseSpec& aSpec,
                                    PBackgroundIDBFactoryRequestChild* aRequest)
                                    override;
 
   virtual bool
   DeallocPBackgroundIDBDatabaseChild(PBackgroundIDBDatabaseChild* aActor)
                                      override;
 
+  mozilla::ipc::IPCResult
+  RecvPBackgroundIDBDatabaseConstructor(
+                                    PBackgroundIDBDatabaseChild* aActor,
+                                    const DatabaseSpec& aSpec,
+                                    PBackgroundIDBFactoryRequestChild* aRequest)
+                                    override;
+
   bool
   SendDeleteMe() = delete;
 };
 
 class BackgroundDatabaseChild;
 
 class BackgroundRequestChildBase
 {
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -712,16 +712,18 @@ IDBDatabase::Transaction(JSContext* aCx,
                transaction->LoggingSerialNumber(),
                IDB_LOG_STRINGIFY(this),
                IDB_LOG_STRINGIFY(transaction));
 
   MOZ_ALWAYS_TRUE(
     mBackgroundActor->SendPBackgroundIDBTransactionConstructor(actor,
                                                                sortedStoreNames,
                                                                mode));
+  MOZ_ASSERT(actor->GetActorEventTarget(),
+    "The event target shall be inherited from it manager actor.");
 
   transaction->SetBackgroundActor(actor);
 
   if (mode == IDBTransaction::CLEANUP) {
     ExpireFileActors(/* aExpireAll */ true);
   }
 
   transaction.forget(aTransaction);
@@ -774,16 +776,19 @@ IDBDatabase::CreateMutableFile(JSContext
                "IndexedDB %s: C R[%llu]: IDBDatabase.createMutableFile()",
                IDB_LOG_ID_STRING(),
                request->LoggingSerialNumber(),
                IDB_LOG_STRINGIFY(this),
                NS_ConvertUTF16toUTF8(aName).get());
 
   mBackgroundActor->SendPBackgroundIDBDatabaseRequestConstructor(actor, params);
 
+  MOZ_ASSERT(actor->GetActorEventTarget(),
+    "The event target shall be inherited from its manager actor.");
+
   return request.forget();
 }
 
 void
 IDBDatabase::RegisterTransaction(IDBTransaction* aTransaction)
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aTransaction);
@@ -944,16 +949,19 @@ IDBDatabase::GetOrCreateFileActorForBlob
       auto* dbFile = new DatabaseFile(this);
 
       actor =
         mBackgroundActor->SendPBackgroundIDBDatabaseFileConstructor(dbFile,
                                                                     blobChild);
       if (NS_WARN_IF(!actor)) {
         return nullptr;
       }
+
+      MOZ_ASSERT(actor->GetActorEventTarget(),
+        "The event target shall be inherited from its manager actor.");
     } else {
       // Make sure that the input stream we get here is one that can actually be
       // serialized to PBackground.
       PBackgroundChild* backgroundManager =
         mBackgroundActor->Manager()->Manager();
       MOZ_ASSERT(backgroundManager);
 
       auto* blobChild =
@@ -964,16 +972,19 @@ IDBDatabase::GetOrCreateFileActorForBlob
       auto* dbFile = new DatabaseFile(this);
 
       actor =
         mBackgroundActor->SendPBackgroundIDBDatabaseFileConstructor(dbFile,
                                                                     blobChild);
       if (NS_WARN_IF(!actor)) {
         return nullptr;
       }
+
+      MOZ_ASSERT(actor->GetActorEventTarget(),
+        "The event target shall be inherited from its manager actor.");
     }
 
     MOZ_ASSERT(actor);
 
     mFileActors.Put(weakRef, actor);
   }
 
   MOZ_ASSERT(actor);
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -792,17 +792,17 @@ IDBFactory::BackgroundActorCreated(PBack
   MOZ_ASSERT(!mBackgroundActorFailed);
 
   {
     BackgroundFactoryChild* actor = new BackgroundFactoryChild(this);
 
     // Set EventTarget for the top-level actor.
     // All child actors created later inherit the same event target.
     aBackgroundActor->SetEventTargetForActor(actor, EventTarget());
-
+    MOZ_ASSERT(actor->GetActorEventTarget());
     mBackgroundActor =
       static_cast<BackgroundFactoryChild*>(
         aBackgroundActor->SendPBackgroundIDBFactoryConstructor(actor,
                                                                aLoggingInfo));
   }
 
   if (NS_WARN_IF(!mBackgroundActor)) {
     BackgroundActorFailed();
@@ -889,16 +889,19 @@ IDBFactory::InitiateRequest(IDBOpenDBReq
                                       requestedVersion);
 
   if (!mBackgroundActor->SendPBackgroundIDBFactoryRequestConstructor(actor,
                                                                      aParams)) {
     aRequest->DispatchNonTransactionError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
+  MOZ_ASSERT(actor->GetActorEventTarget(),
+    "The event target shall be inherited from its manager actor.");
+
   return NS_OK;
 }
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBFactory)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBFactory)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBFactory)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -302,16 +302,19 @@ IDBTransaction::StartRequest(IDBRequest*
       SendPBackgroundIDBRequestConstructor(actor, aParams);
   } else {
     MOZ_ASSERT(mBackgroundActor.mNormalBackgroundActor);
 
     mBackgroundActor.mNormalBackgroundActor->
       SendPBackgroundIDBRequestConstructor(actor, aParams);
   }
 
+  MOZ_ASSERT(actor->GetActorEventTarget(),
+    "The event target shall be inherited from its manager actor.");
+
   // Balanced in BackgroundRequestChild::Recv__delete__().
   OnNewRequest();
 
   return actor;
 }
 
 void
 IDBTransaction::OpenCursor(BackgroundCursorChild* aBackgroundActor,
@@ -328,16 +331,19 @@ IDBTransaction::OpenCursor(BackgroundCur
       SendPBackgroundIDBCursorConstructor(aBackgroundActor, aParams);
   } else {
     MOZ_ASSERT(mBackgroundActor.mNormalBackgroundActor);
 
     mBackgroundActor.mNormalBackgroundActor->
       SendPBackgroundIDBCursorConstructor(aBackgroundActor, aParams);
   }
 
+  MOZ_ASSERT(aBackgroundActor->GetActorEventTarget(),
+    "The event target shall be inherited from its manager actor.");
+
   // Balanced in BackgroundCursorChild::RecvResponse().
   OnNewRequest();
 }
 
 void
 IDBTransaction::RefreshSpec(bool aMayDelete)
 {
   AssertIsOnOwningThread();