Bug 1350637 - Part 8: Implement BackgroundParent::GetLiveActorArray. r=billm, a=lizzard
authorJan Varga <jan.varga@gmail.com>
Tue, 08 Aug 2017 23:02:16 +0200
changeset 421301 e78fed3a2212
parent 421300 8267e1dbf9bc
child 421302 4a23be8a7089
push id7647
push userryanvm@gmail.com
push dateMon, 21 Aug 2017 19:15:39 +0000
treeherdermozilla-beta@6a2167880016 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, lizzard
bugs1350637
milestone56.0
Bug 1350637 - Part 8: Implement BackgroundParent::GetLiveActorArray. r=billm, a=lizzard
ipc/glue/BackgroundImpl.cpp
ipc/glue/BackgroundParent.h
--- a/ipc/glue/BackgroundImpl.cpp
+++ b/ipc/glue/BackgroundImpl.cpp
@@ -211,16 +211,21 @@ private:
   GetRawContentParentForComparison(PBackgroundParent* aBackgroundActor);
 
   // Forwarded from BackgroundParent.
   static uint64_t
   GetChildID(PBackgroundParent* aBackgroundActor);
 
   // Forwarded from BackgroundParent.
   static bool
+  GetLiveActorArray(PBackgroundParent* aBackgroundActor,
+                    nsTArray<PBackgroundParent*>& aLiveActorArray);
+
+  // Forwarded from BackgroundParent.
+  static bool
   Alloc(ContentParent* aContent,
         Endpoint<PBackgroundParent>&& aEndpoint);
 
   static bool
   CreateBackgroundThread();
 
   static void
   ShutdownBackgroundThread();
@@ -700,16 +705,25 @@ BackgroundParent::GetRawContentParentFor
 uint64_t
 BackgroundParent::GetChildID(PBackgroundParent* aBackgroundActor)
 {
   return ParentImpl::GetChildID(aBackgroundActor);
 }
 
 // static
 bool
+BackgroundParent::GetLiveActorArray(
+                                  PBackgroundParent* aBackgroundActor,
+                                  nsTArray<PBackgroundParent*>& aLiveActorArray)
+{
+  return ParentImpl::GetLiveActorArray(aBackgroundActor, aLiveActorArray);
+}
+
+// static
+bool
 BackgroundParent::Alloc(ContentParent* aContent,
                         Endpoint<PBackgroundParent>&& aEndpoint)
 {
   return ParentImpl::Alloc(aContent, Move(aEndpoint));
 }
 
 // -----------------------------------------------------------------------------
 // BackgroundChild Public Methods
@@ -868,16 +882,43 @@ ParentImpl::GetChildID(PBackgroundParent
     return actor->mContent->ChildID();
   }
 
   return 0;
 }
 
 // static
 bool
+ParentImpl::GetLiveActorArray(PBackgroundParent* aBackgroundActor,
+                              nsTArray<PBackgroundParent*>& aLiveActorArray)
+{
+  AssertIsOnBackgroundThread();
+  MOZ_ASSERT(aBackgroundActor);
+  MOZ_ASSERT(aLiveActorArray.IsEmpty());
+
+  auto actor = static_cast<ParentImpl*>(aBackgroundActor);
+  if (actor->mActorDestroyed) {
+    MOZ_ASSERT(false,
+               "GetLiveActorArray called after ActorDestroy was called!");
+    return false;
+  }
+
+  if (!actor->mLiveActorArray) {
+    return true;
+  }
+
+  for (ParentImpl* liveActor : *actor->mLiveActorArray) {
+    aLiveActorArray.AppendElement(liveActor);
+  }
+
+  return true;
+}
+
+// static
+bool
 ParentImpl::Alloc(ContentParent* aContent,
                   Endpoint<PBackgroundParent>&& aEndpoint)
 {
   AssertIsInMainProcess();
   AssertIsOnMainThread();
   MOZ_ASSERT(aEndpoint.IsValid());
 
   if (!sBackgroundThread && !CreateBackgroundThread()) {
--- a/ipc/glue/BackgroundParent.h
+++ b/ipc/glue/BackgroundParent.h
@@ -62,16 +62,20 @@ public:
   // ContentParent after the ContentParent has died. This function may only be
   // called on the background thread.
   static intptr_t
   GetRawContentParentForComparison(PBackgroundParent* aBackgroundActor);
 
   static uint64_t
   GetChildID(PBackgroundParent* aBackgroundActor);
 
+  static bool
+  GetLiveActorArray(PBackgroundParent* aBackgroundActor,
+                    nsTArray<PBackgroundParent*>& aLiveActorArray);
+
 private:
   // Only called by ContentParent for cross-process actors.
   static bool
   Alloc(ContentParent* aContent,
         Endpoint<PBackgroundParent>&& aEndpoint);
 };
 
 // Implemented in BackgroundImpl.cpp.