Ensure IPDL owns a reference to ImageBridgeChild. (bug 1298938 part 6, r=billm)
☠☠ backed out by 1222234def49 ☠ ☠
authorDavid Anderson <danderson@mozilla.com>
Thu, 08 Sep 2016 11:29:32 -0700
changeset 354629 d710b5ac1e138892fa1d7bcbcd37d3e67ad1506e
parent 354628 df832e32e7aacff4b61470edaa84e6e9b882e7d2
child 354630 f41a22a14e0db226793f5912caa31548d44aa6ea
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1298938
milestone51.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
Ensure IPDL owns a reference to ImageBridgeChild. (bug 1298938 part 6, r=billm)
gfx/layers/ipc/ImageBridgeChild.cpp
gfx/layers/ipc/ImageBridgeChild.h
--- a/gfx/layers/ipc/ImageBridgeChild.cpp
+++ b/gfx/layers/ipc/ImageBridgeChild.cpp
@@ -491,26 +491,34 @@ ImageBridgeChild::ShutdownStep1(Synchron
 void
 ImageBridgeChild::ShutdownStep2(SynchronousTask* aTask)
 {
   AutoCompleteTask complete(aTask);
 
   MOZ_ASSERT(InImageBridgeChildThread(),
              "Should be in ImageBridgeChild thread.");
 
-  Close();
+  if (mCanSend) {
+    Close();
+  }
 }
 
 void
 ImageBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
 {
   mCanSend = false;
 }
 
 void
+ImageBridgeChild::DeallocPImageBridgeChild()
+{
+  this->Release();
+}
+
+void
 ImageBridgeChild::CreateImageClientSync(SynchronousTask* aTask,
                                         RefPtr<ImageClient>* result,
                                         CompositableType aType,
                                         ImageContainer* aImageContainer,
                                         ImageContainerChild* aContainerChild)
 {
   AutoCompleteTask complete(aTask);
   *result = CreateImageClientNow(aType, aImageContainer, aContainerChild);
@@ -901,30 +909,34 @@ ImageBridgeChild::InitForContent(Endpoin
 
 void
 ImageBridgeChild::Bind(Endpoint<PImageBridgeChild>&& aEndpoint)
 {
   if (!aEndpoint.Bind(this)) {
     return;
   }
 
+  // This reference is dropped in DeallocPImageBridgeChild.
+  this->AddRef();
+
   mCanSend = true;
-
   SendImageBridgeThreadId();
 }
 
 void
 ImageBridgeChild::BindSameProcess(RefPtr<ImageBridgeParent> aParent)
 {
   MessageLoop *parentMsgLoop = aParent->GetMessageLoop();
   ipc::MessageChannel *parentChannel = aParent->GetIPCChannel();
   Open(parentChannel, parentMsgLoop, mozilla::ipc::ChildSide);
 
+  // This reference is dropped in DeallocPImageBridgeChild.
+  this->AddRef();
+
   mCanSend = true;
-
   SendImageBridgeThreadId();
 }
 
 void ImageBridgeChild::ShutDown()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (RefPtr<ImageBridgeChild> child = GetSingleton()) {
--- a/gfx/layers/ipc/ImageBridgeChild.h
+++ b/gfx/layers/ipc/ImageBridgeChild.h
@@ -381,16 +381,17 @@ protected:
 
   void WillShutdown();
   void ShutdownStep1(SynchronousTask* aTask);
   void ShutdownStep2(SynchronousTask* aTask);
   void MarkShutDown();
   void FallbackDestroyActors();
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
+  void DeallocPImageBridgeChild() override;
 
   bool CanSend() const;
 
 private:
   class ShutdownObserver final : public nsIObserver
   {
   public:
     NS_DECL_ISUPPORTS