Bug 1350637 - Part 8: Implement BackgroundParent::GetLiveActorArray; r=billm
authorJan Varga <jan.varga@gmail.com>
Tue, 08 Aug 2017 23:02:16 +0200
changeset 373417 ddbbf8aa33dc
parent 373416 28506433e4f0
child 373418 bbc3dc385fac
push id93520
push userjvarga@mozilla.com
push dateTue, 08 Aug 2017 21:35:35 +0000
treeherdermozilla-inbound@042120b49ceb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1350637
milestone57.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 1350637 - Part 8: Implement BackgroundParent::GetLiveActorArray; r=billm
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.