diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index 24d079d9916a..2bc0282afa5b 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -42,7 +42,7 @@ using namespace mozilla::ipc; using namespace mozilla::gfx; using namespace mozilla::media; -std::map ImageBridgeParent::sImageBridges; +ImageBridgeParent::ImageBridgeMap ImageBridgeParent::sImageBridges; StaticAutoPtr sImageBridgesLock; @@ -369,8 +369,9 @@ ImageBridgeParent::NotifyImageComposites(nsTArraySendPendingAsyncMessages(); - if (!GetInstance(pid)->SendDidComposite(notifications)) { + RefPtr bridge = GetInstance(pid); + bridge->SendPendingAsyncMessages(); + if (!bridge->SendDidComposite(notifications)) { ok = false; } i = end; @@ -385,13 +386,18 @@ ImageBridgeParent::DeferredDestroy() mSelfRef = nullptr; // "this" ImageBridge may get deleted here. } -RefPtr +already_AddRefed ImageBridgeParent::GetInstance(ProcessId aId) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); MonitorAutoLock lock(*sImageBridgesLock); - NS_ASSERTION(sImageBridges.count(aId) == 1, "ImageBridgeParent for the process"); - return sImageBridges[aId]; + ImageBridgeMap::const_iterator i = sImageBridges.find(aId); + if (i == sImageBridges.end()) { + NS_ASSERTION(false, "Cannot find image bridge for process!"); + return nullptr; + } + RefPtr bridge = i->second; + return bridge.forget(); } bool diff --git a/gfx/layers/ipc/ImageBridgeParent.h b/gfx/layers/ipc/ImageBridgeParent.h index 515c5dca1708..0838025360fc 100644 --- a/gfx/layers/ipc/ImageBridgeParent.h +++ b/gfx/layers/ipc/ImageBridgeParent.h @@ -114,7 +114,7 @@ public: virtual bool IsSameProcess() const override; - static RefPtr GetInstance(ProcessId aId); + static already_AddRefed GetInstance(ProcessId aId); static bool NotifyImageComposites(nsTArray& aNotifications); @@ -140,7 +140,8 @@ private: /** * Map of all living ImageBridgeParent instances */ - static std::map sImageBridges; + typedef std::map ImageBridgeMap; + static ImageBridgeMap sImageBridges; RefPtr mCompositorThreadHolder; };