Bug 1561179 - P2: Rename VideoBridge methods and members. r=mattwoodrow
authorDan Glastonbury <dan.glastonbury@gmail.com>
Mon, 04 Nov 2019 03:41:47 +0000
changeset 500313 8b9accb338043f9e7cdeb90f77b76927cd19a143
parent 500312 9942990fbff5baf5c76aa811fa43896b5c678d39
child 500314 dc3f655d626efcbff67d819f0195d56e06f8cd43
push id36761
push userdvarga@mozilla.com
push dateMon, 04 Nov 2019 09:41:18 +0000
treeherdermozilla-central@5647ec4ba6f2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1561179
milestone72.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 1561179 - P2: Rename VideoBridge methods and members. r=mattwoodrow To bring the naming more inline with ImageBridge. Differential Revision: https://phabricator.services.mozilla.com/D50399
dom/media/ipc/RDDProcessManager.cpp
gfx/layers/ipc/VideoBridgeChild.cpp
gfx/layers/ipc/VideoBridgeParent.cpp
gfx/layers/ipc/VideoBridgeParent.h
--- a/dom/media/ipc/RDDProcessManager.cpp
+++ b/dom/media/ipc/RDDProcessManager.cpp
@@ -173,19 +173,17 @@ void RDDProcessManager::OnProcessLaunchC
     MOZ_LOG(sPDMLog, LogLevel::Debug,
             ("Could not create video bridge: %d", int(rv)));
     DestroyProcess();
     return;
   }
 
   mRDDChild->SendCreateVideoBridgeToParentProcess(std::move(childPipe));
 
-  CompositorThreadHolder::Loop()->PostTask(
-      NewRunnableFunction("gfx::VideoBridgeParent::Open",
-                          &VideoBridgeParent::Open, std::move(parentPipe), VideoBridgeSource::RddProcess));
+  VideoBridgeParent::CreateForContent(std::move(parentPipe));
 
   CrashReporter::AnnotateCrashReport(
       CrashReporter::Annotation::RDDProcessStatus,
       NS_LITERAL_CSTRING("Running"));
 }
 
 void RDDProcessManager::OnProcessUnexpectedShutdown(RDDProcessHost* aHost) {
   MOZ_ASSERT(mProcess && mProcess == aHost);
--- a/gfx/layers/ipc/VideoBridgeChild.cpp
+++ b/gfx/layers/ipc/VideoBridgeChild.cpp
@@ -19,39 +19,36 @@ void VideoBridgeChild::StartupForGPUProc
   ipc::Endpoint<PVideoBridgeParent> parentPipe;
   ipc::Endpoint<PVideoBridgeChild> childPipe;
 
   PVideoBridge::CreateEndpoints(base::GetCurrentProcId(),
                                 base::GetCurrentProcId(), &parentPipe,
                                 &childPipe);
 
   VideoBridgeChild::OpenToGPUProcess(std::move(childPipe));
-
-  CompositorThreadHolder::Loop()->PostTask(NewRunnableFunction(
-      "gfx::VideoBridgeParent::Open", &VideoBridgeParent::Open,
-      std::move(parentPipe), VideoBridgeSource::GpuProcess));
+  VideoBridgeParent::CreateForGPUProcess(std::move(parentPipe), VideoBridgeSource::GpuProcess);
 }
 
 void VideoBridgeChild::OpenToParentProcess(
     Endpoint<PVideoBridgeChild>&& aEndpoint) {
   sVideoBridgeToParentProcess = new VideoBridgeChild();
 
   if (!aEndpoint.Bind(sVideoBridgeToParentProcess)) {
     // We can't recover from this.
-    MOZ_CRASH("Failed to bind RemoteDecoderManagerParent to endpoint");
+    MOZ_CRASH("Failed to bind VideoBridgeChild to endpoint");
   }
 }
 
 void VideoBridgeChild::OpenToGPUProcess(
     Endpoint<PVideoBridgeChild>&& aEndpoint) {
   sVideoBridgeToGPUProcess = new VideoBridgeChild();
 
   if (!aEndpoint.Bind(sVideoBridgeToGPUProcess)) {
     // We can't recover from this.
-    MOZ_CRASH("Failed to bind RemoteDecoderManagerParent to endpoint");
+    MOZ_CRASH("Failed to bind VideoBridgeChild to endpoint");
   }
 }
 
 /* static */
 void VideoBridgeChild::Shutdown() {
   if (sVideoBridgeToParentProcess) {
     sVideoBridgeToParentProcess->Close();
     sVideoBridgeToParentProcess = nullptr;
--- a/gfx/layers/ipc/VideoBridgeParent.cpp
+++ b/gfx/layers/ipc/VideoBridgeParent.cpp
@@ -14,46 +14,70 @@ namespace layers {
 
 using namespace mozilla::ipc;
 using namespace mozilla::gfx;
 
 static VideoBridgeParent* sVideoBridgeFromRddProcess;
 static VideoBridgeParent* sVideoBridgeFromGpuProcess;
 
 VideoBridgeParent::VideoBridgeParent(VideoBridgeSource aSource)
-    : mClosed(false) {
+    : mCompositorThreadHolder(CompositorThreadHolder::GetSingleton()),
+      mClosed(false) {
   mSelfRef = this;
   switch (aSource) {
     default:
       MOZ_CRASH("Unhandled case");
     case VideoBridgeSource::RddProcess:
       sVideoBridgeFromRddProcess = this;
       break;
     case VideoBridgeSource::GpuProcess:
       sVideoBridgeFromGpuProcess = this;
       break;
   }
-  mCompositorThreadRef = CompositorThreadHolder::GetSingleton();
 }
 
 VideoBridgeParent::~VideoBridgeParent() {
   if (sVideoBridgeFromRddProcess == this) {
     sVideoBridgeFromRddProcess = nullptr;
   }
   if (sVideoBridgeFromGpuProcess == this) {
     sVideoBridgeFromGpuProcess = nullptr;
   }
 }
 
-void VideoBridgeParent::Open(Endpoint<PVideoBridgeParent>&& aEndpoint,
-                             VideoBridgeSource aSource) {
+/* static */
+void VideoBridgeParent::CreateForGPUProcess(
+    Endpoint<PVideoBridgeParent>&& aEndpoint, VideoBridgeSource aSource) {
+  MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_GPU);
   RefPtr<VideoBridgeParent> parent = new VideoBridgeParent(aSource);
-  if (!aEndpoint.Bind(parent)) {
+
+  CompositorThreadHolder::Loop()->PostTask(
+      NewRunnableMethod<Endpoint<PVideoBridgeParent>&&>(
+          "gfx::layers::VideoBridgeParent::Bind", parent,
+          &VideoBridgeParent::Bind, std::move(aEndpoint)));
+}
+
+/* static */
+void VideoBridgeParent::CreateForContent(
+    Endpoint<PVideoBridgeParent>&& aEndpoint) {
+  MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+  RefPtr<VideoBridgeParent> parent =
+      new VideoBridgeParent(VideoBridgeSource::RddProcess);
+
+  CompositorThreadHolder::Loop()->PostTask(
+      NewRunnableMethod<Endpoint<PVideoBridgeParent>&&>(
+          "gfx::layers::VideoBridgeParent::Bind", parent,
+          &VideoBridgeParent::Bind, std::move(aEndpoint)));
+}
+
+
+void VideoBridgeParent::Bind(Endpoint<PVideoBridgeParent>&& aEndpoint) {
+  if (!aEndpoint.Bind(this)) {
     // We can't recover from this.
-    MOZ_CRASH("Failed to bind RemoteDecoderManagerParent to endpoint");
+    MOZ_CRASH("Failed to bind VideoBridgeParent to endpoint");
   }
 }
 
 /* static */
 VideoBridgeParent* VideoBridgeParent::GetSingleton(
     Maybe<VideoBridgeSource>& aSource) {
   MOZ_ASSERT(aSource.isSome());
   switch (aSource.value()) {
@@ -73,17 +97,17 @@ TextureHost* VideoBridgeParent::LookupTe
 }
 
 void VideoBridgeParent::ActorDestroy(ActorDestroyReason aWhy) {
   // Can't alloc/dealloc shmems from now on.
   mClosed = true;
 }
 
 void VideoBridgeParent::ActorDealloc() {
-  mCompositorThreadRef = nullptr;
+  mCompositorThreadHolder = nullptr;
   mSelfRef = nullptr;
 }
 
 PTextureParent* VideoBridgeParent::AllocPTextureParent(
     const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock,
     const LayersBackend& aLayersBackend, const TextureFlags& aFlags,
     const uint64_t& aSerial) {
   PTextureParent* parent = TextureHost::CreateIPDLActor(
--- a/gfx/layers/ipc/VideoBridgeParent.h
+++ b/gfx/layers/ipc/VideoBridgeParent.h
@@ -19,16 +19,20 @@ class CompositorThreadHolder;
 class VideoBridgeParent final : public PVideoBridgeParent,
                                 public HostIPCAllocator,
                                 public ShmemAllocator {
  public:
   ~VideoBridgeParent();
 
   static VideoBridgeParent* GetSingleton(Maybe<VideoBridgeSource>& aSource);
 
+  static void CreateForGPUProcess(Endpoint<PVideoBridgeParent>&& aEndpoint,
+                                  VideoBridgeSource aSource);
+  static void CreateForContent(Endpoint<PVideoBridgeParent>&& aEndpoint);
+
   TextureHost* LookupTexture(uint64_t aSerial);
 
   // PVideoBridgeParent
   void ActorDestroy(ActorDestroyReason aWhy) override;
   PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
                                       const ReadLockDescriptor& aReadLock,
                                       const LayersBackend& aLayersBackend,
                                       const TextureFlags& aFlags,
@@ -51,28 +55,26 @@ class VideoBridgeParent final : public P
   bool AllocShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
                   ipc::Shmem* aShmem) override;
 
   bool AllocUnsafeShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
                         ipc::Shmem* aShmem) override;
 
   void DeallocShmem(ipc::Shmem& aShmem) override;
 
-  static void Open(Endpoint<PVideoBridgeParent>&& aEndpoint,
-                   VideoBridgeSource aSource);
-
  private:
   explicit VideoBridgeParent(VideoBridgeSource aSource);
+  void Bind(Endpoint<PVideoBridgeParent>&& aEndpoint);
 
   void ActorDealloc() override;
 
   // This keeps us alive until ActorDestroy(), at which point we do a
   // deferred destruction of ourselves.
   RefPtr<VideoBridgeParent> mSelfRef;
-  RefPtr<CompositorThreadHolder> mCompositorThreadRef;
+  RefPtr<CompositorThreadHolder> mCompositorThreadHolder;
 
   std::map<uint64_t, PTextureParent*> mTextureMap;
 
   bool mClosed;
 };
 
 }  // namespace layers
 }  // namespace mozilla