From 2f5eb1251652474371f6a0689c0d863c8727f36b Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 5 Jul 2022 20:08:31 +0000 Subject: [PATCH] Bug 1777656: Delete mozilla::ipc::SharedMemory::SharedMemorytype. r=nika,media-playback-reviewers,padenot Differential Revision: https://phabricator.services.mozilla.com/D150852 --- dom/base/nsContentUtils.cpp | 4 +- dom/canvas/ClientWebGLContext.cpp | 4 +- dom/canvas/WebGLChild.cpp | 4 +- dom/canvas/WebGLIpdl.h | 7 ++-- dom/canvas/WebGLParent.cpp | 12 ++---- dom/media/gmp/ChromiumCDMParent.cpp | 4 +- dom/media/gmp/GMPSharedMemManager.cpp | 7 ++-- dom/media/gmp/GMPSharedMemManager.h | 8 +--- dom/media/gmp/GMPVideoDecoderChild.cpp | 4 +- dom/media/gmp/GMPVideoDecoderChild.h | 3 +- dom/media/gmp/GMPVideoDecoderParent.cpp | 5 +-- dom/media/gmp/GMPVideoDecoderParent.h | 5 +-- dom/media/gmp/GMPVideoEncodedFrameImpl.cpp | 10 ++--- dom/media/gmp/GMPVideoEncoderChild.cpp | 6 +-- dom/media/gmp/GMPVideoEncoderChild.h | 3 +- dom/media/gmp/GMPVideoEncoderParent.cpp | 5 +-- dom/media/gmp/GMPVideoEncoderParent.h | 5 +-- dom/media/gmp/GMPVideoPlaneImpl.cpp | 5 +-- dom/media/ipc/RemoteDecoderManagerChild.h | 13 ++---- dom/media/ipc/RemoteDecoderManagerParent.cpp | 3 +- dom/media/systemservices/ShmemPool.h | 6 +-- dom/webgpu/Device.cpp | 3 +- dom/webgpu/Queue.cpp | 6 +-- dom/webgpu/ipc/WebGPUParent.cpp | 2 +- gfx/ipc/GfxMessageUtils.h | 3 +- gfx/layers/BufferTexture.cpp | 4 +- gfx/layers/ipc/CompositorBridgeChild.cpp | 12 ++---- gfx/layers/ipc/CompositorBridgeChild.h | 8 +--- gfx/layers/ipc/CompositorBridgeParent.cpp | 15 +++---- gfx/layers/ipc/CompositorBridgeParent.h | 8 +--- gfx/layers/ipc/ISurfaceAllocator.cpp | 7 +--- gfx/layers/ipc/ISurfaceAllocator.h | 2 - gfx/layers/ipc/ImageBridgeChild.cpp | 29 ++++++------- gfx/layers/ipc/ImageBridgeChild.h | 13 ++---- gfx/layers/ipc/ImageBridgeParent.cpp | 12 ++---- gfx/layers/ipc/ImageBridgeParent.h | 6 +-- gfx/layers/ipc/RefCountedShmem.cpp | 3 +- .../ipc/UiCompositorControllerParent.cpp | 2 +- gfx/layers/ipc/VideoBridgeChild.cpp | 28 +++++-------- gfx/layers/ipc/VideoBridgeChild.h | 14 ++----- gfx/layers/ipc/VideoBridgeParent.cpp | 12 ++---- gfx/layers/ipc/VideoBridgeParent.h | 6 +-- gfx/layers/wr/IpcResourceUpdateQueue.cpp | 3 +- gfx/thebes/gfxBaseSharedMemorySurface.h | 25 +++++------ ipc/glue/ProtocolUtils.cpp | 27 +++++------- ipc/glue/ProtocolUtils.h | 39 +++++++----------- ipc/glue/SharedMemory.h | 4 -- ipc/glue/SharedMemoryBasic_android.h | 2 - ipc/glue/SharedMemoryBasic_chromium.h | 2 - ipc/glue/SharedMemoryBasic_mach.h | 2 - ipc/glue/Shmem.cpp | 41 ++++++------------- ipc/glue/Shmem.h | 2 - ipc/ipdl/test/cxx/TestShmem.cpp | 6 +-- tools/fuzzing/ipc/ProtocolFuzzer.h | 3 +- tools/profiler/gecko/ProfilerChild.cpp | 10 ++--- 55 files changed, 165 insertions(+), 319 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index a48e599d7c85..8b2b72a552e2 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -7875,7 +7875,7 @@ static bool AllocateShmem(mozilla::dom::ContentChild* aChild, IShmemAllocator* allocator = aChild ? static_cast(aChild) : static_cast(aParent); - return allocator->AllocShmem(aSize, SharedMemory::TYPE_BASIC, aShmem); + return allocator->AllocShmem(aSize, aShmem); } static Shmem ConvertToShmem(mozilla::dom::ContentChild* aChild, @@ -8166,7 +8166,7 @@ struct GetSurfaceDataShmem { ReturnType Allocate(size_t aSize) { Shmem shmem; - if (!mAllocator->AllocShmem(aSize, SharedMemory::TYPE_BASIC, &shmem)) { + if (!mAllocator->AllocShmem(aSize, &shmem)) { return Nothing(); } diff --git a/dom/canvas/ClientWebGLContext.cpp b/dom/canvas/ClientWebGLContext.cpp index 783224ec8a32..69f9e1639d37 100644 --- a/dom/canvas/ClientWebGLContext.cpp +++ b/dom/canvas/ClientWebGLContext.cpp @@ -4310,10 +4310,8 @@ void ClientWebGLContext::TexImage(uint8_t funcDims, GLenum imageTarget, MOZ_ASSERT(desc->sd); const auto byteCount = pShmem->Size(); const auto* const src = pShmem->get(); - const auto shmemType = - mozilla::ipc::SharedMemory::SharedMemoryType::TYPE_BASIC; mozilla::ipc::Shmem shmemForResend; - if (!child->AllocShmem(byteCount, shmemType, &shmemForResend)) { + if (!child->AllocShmem(byteCount, &shmemForResend)) { NS_WARNING("AllocShmem failed in TexImage"); return; } diff --git a/dom/canvas/WebGLChild.cpp b/dom/canvas/WebGLChild.cpp index a9985731f560..70e072866b77 100644 --- a/dom/canvas/WebGLChild.cpp +++ b/dom/canvas/WebGLChild.cpp @@ -30,9 +30,7 @@ Maybe> WebGLChild::AllocPendingCmdBytes(const size_t size) { capacity = size; } - auto shmem = webgl::RaiiShmem::Alloc( - this, capacity, - mozilla::ipc::SharedMemory::SharedMemoryType::TYPE_BASIC); + auto shmem = webgl::RaiiShmem::Alloc(this, capacity); if (!shmem) { NS_WARNING("Failed to alloc shmem for AllocPendingCmdBytes."); return {}; diff --git a/dom/canvas/WebGLIpdl.h b/dom/canvas/WebGLIpdl.h index 8ccaded1bfd8..e66529012608 100644 --- a/dom/canvas/WebGLIpdl.h +++ b/dom/canvas/WebGLIpdl.h @@ -27,11 +27,10 @@ class RaiiShmem final { public: /// Returns zeroed data. - static RaiiShmem Alloc( - mozilla::ipc::IProtocol* const allocator, const size_t size, - const mozilla::ipc::SharedMemory::SharedMemoryType type) { + static RaiiShmem Alloc(mozilla::ipc::IProtocol* const allocator, + const size_t size) { mozilla::ipc::Shmem shmem; - if (!allocator->AllocShmem(size, type, &shmem)) return {}; + if (!allocator->AllocShmem(size, &shmem)) return {}; return {allocator, shmem}; } diff --git a/dom/canvas/WebGLParent.cpp b/dom/canvas/WebGLParent.cpp index 0331c5c03811..3a7527b34a0b 100644 --- a/dom/canvas/WebGLParent.cpp +++ b/dom/canvas/WebGLParent.cpp @@ -127,9 +127,7 @@ IPCResult WebGLParent::GetFrontBufferSnapshot( const auto& surfSize = *maybeSize; const auto byteSize = 4 * surfSize.x * surfSize.y; - auto shmem = webgl::RaiiShmem::Alloc( - aProtocol, byteSize, - mozilla::ipc::SharedMemory::SharedMemoryType::TYPE_BASIC); + auto shmem = webgl::RaiiShmem::Alloc(aProtocol, byteSize); if (!shmem) { NS_WARNING("Failed to alloc shmem for RecvGetFrontBufferSnapshot."); return IPC_FAIL(aProtocol, "Failed to allocate shmem for result"); @@ -158,9 +156,7 @@ IPCResult WebGLParent::RecvGetBufferSubData(const GLenum target, } const auto allocSize = 1 + byteSize; - auto shmem = webgl::RaiiShmem::Alloc( - this, allocSize, - mozilla::ipc::SharedMemory::SharedMemoryType::TYPE_BASIC); + auto shmem = webgl::RaiiShmem::Alloc(this, allocSize); if (!shmem) { NS_WARNING("Failed to alloc shmem for RecvGetBufferSubData."); return IPC_FAIL(this, "Failed to allocate shmem for result"); @@ -188,9 +184,7 @@ IPCResult WebGLParent::RecvReadPixels(const webgl::ReadPixelsDesc& desc, } const auto allocSize = std::max(1, byteSize); - auto shmem = webgl::RaiiShmem::Alloc( - this, allocSize, - mozilla::ipc::SharedMemory::SharedMemoryType::TYPE_BASIC); + auto shmem = webgl::RaiiShmem::Alloc(this, allocSize); if (!shmem) { NS_WARNING("Failed to alloc shmem for RecvReadPixels."); return IPC_FAIL(this, "Failed to allocate shmem for result"); diff --git a/dom/media/gmp/ChromiumCDMParent.cpp b/dom/media/gmp/ChromiumCDMParent.cpp index b402efcd9e02..0996561b90de 100644 --- a/dom/media/gmp/ChromiumCDMParent.cpp +++ b/dom/media/gmp/ChromiumCDMParent.cpp @@ -352,7 +352,7 @@ bool ChromiumCDMParent::InitCDMInputBuffer(gmp::CDMInputBuffer& aBuffer, } Shmem shmem; - if (!AllocShmem(aSample->Size(), Shmem::SharedMemory::TYPE_BASIC, &shmem)) { + if (!AllocShmem(aSample->Size(), &shmem)) { return false; } memcpy(shmem.get(), aSample->Data(), aSample->Size()); @@ -391,7 +391,7 @@ bool ChromiumCDMParent::SendBufferToCDM(uint32_t aSizeInBytes) { GMP_LOG_DEBUG("ChromiumCDMParent::SendBufferToCDM() size=%" PRIu32, aSizeInBytes); Shmem shmem; - if (!AllocShmem(aSizeInBytes, Shmem::SharedMemory::TYPE_BASIC, &shmem)) { + if (!AllocShmem(aSizeInBytes, &shmem)) { return false; } if (!SendGiveBuffer(std::move(shmem))) { diff --git a/dom/media/gmp/GMPSharedMemManager.cpp b/dom/media/gmp/GMPSharedMemManager.cpp index dbb1826b6c96..5da04247cb10 100644 --- a/dom/media/gmp/GMPSharedMemManager.cpp +++ b/dom/media/gmp/GMPSharedMemManager.cpp @@ -18,9 +18,8 @@ namespace mozilla::gmp { // Compressed (encoded) data goes from the Decoder parent to the child; // pool there, and then return with Encoded() frames and goes into the parent // pool. -bool GMPSharedMemManager::MgrAllocShmem( - GMPSharedMem::GMPMemoryClasses aClass, size_t aSize, - ipc::Shmem::SharedMemory::SharedMemoryType aType, ipc::Shmem* aMem) { +bool GMPSharedMemManager::MgrAllocShmem(GMPSharedMem::GMPMemoryClasses aClass, + size_t aSize, ipc::Shmem* aMem) { mData->CheckThread(); // first look to see if we have a free buffer large enough @@ -36,7 +35,7 @@ bool GMPSharedMemManager::MgrAllocShmem( // Didn't find a buffer free with enough space; allocate one size_t pagesize = ipc::SharedMemory::SystemPageSize(); aSize = (aSize + (pagesize - 1)) & ~(pagesize - 1); // round up to page size - bool retval = Alloc(aSize, aType, aMem); + bool retval = Alloc(aSize, aMem); if (retval) { // The allocator (or NeedsShmem call) should never return less than we ask // for... diff --git a/dom/media/gmp/GMPSharedMemManager.h b/dom/media/gmp/GMPSharedMemManager.h index 6f8e4197cfe9..ad4c3d39c288 100644 --- a/dom/media/gmp/GMPSharedMemManager.h +++ b/dom/media/gmp/GMPSharedMemManager.h @@ -52,9 +52,7 @@ class GMPSharedMemManager { virtual ~GMPSharedMemManager() = default; virtual bool MgrAllocShmem(GMPSharedMem::GMPMemoryClasses aClass, - size_t aSize, - ipc::Shmem::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aMem); + size_t aSize, ipc::Shmem* aMem); virtual bool MgrDeallocShmem(GMPSharedMem::GMPMemoryClasses aClass, ipc::Shmem& aMem); @@ -64,9 +62,7 @@ class GMPSharedMemManager { // These have to be implemented using the AllocShmem/etc provided by the // IPDL-generated interfaces, so have the Parent/Child implement them. - virtual bool Alloc(size_t aSize, - ipc::Shmem::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aMem) = 0; + virtual bool Alloc(size_t aSize, ipc::Shmem* aMem) = 0; virtual void Dealloc(ipc::Shmem&& aMem) = 0; private: diff --git a/dom/media/gmp/GMPVideoDecoderChild.cpp b/dom/media/gmp/GMPVideoDecoderChild.cpp index b527ff0b7316..0f605cca9b0c 100644 --- a/dom/media/gmp/GMPVideoDecoderChild.cpp +++ b/dom/media/gmp/GMPVideoDecoderChild.cpp @@ -179,9 +179,7 @@ mozilla::ipc::IPCResult GMPVideoDecoderChild::RecvDecodingComplete() { return IPC_OK(); } -bool GMPVideoDecoderChild::Alloc(size_t aSize, - Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aMem) { +bool GMPVideoDecoderChild::Alloc(size_t aSize, Shmem* aMem) { MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current()); bool rv; diff --git a/dom/media/gmp/GMPVideoDecoderChild.h b/dom/media/gmp/GMPVideoDecoderChild.h index f40d8de50302..3c74e5f02c6a 100644 --- a/dom/media/gmp/GMPVideoDecoderChild.h +++ b/dom/media/gmp/GMPVideoDecoderChild.h @@ -42,8 +42,7 @@ class GMPVideoDecoderChild : public PGMPVideoDecoderChild, void Error(GMPErr aError) override; // GMPSharedMemManager - bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aMem) override; + bool Alloc(size_t aSize, Shmem* aMem) override; void Dealloc(Shmem&& aMem) override; private: diff --git a/dom/media/gmp/GMPVideoDecoderParent.cpp b/dom/media/gmp/GMPVideoDecoderParent.cpp index 0f0d957b1178..4732a99930cf 100644 --- a/dom/media/gmp/GMPVideoDecoderParent.cpp +++ b/dom/media/gmp/GMPVideoDecoderParent.cpp @@ -402,9 +402,8 @@ mozilla::ipc::IPCResult GMPVideoDecoderParent::RecvNeedShmem( const uint32_t& aFrameBufferSize, Shmem* aMem) { ipc::Shmem mem; - if (!mVideoHost.SharedMemMgr()->MgrAllocShmem( - GMPSharedMem::kGMPFrameData, aFrameBufferSize, - ipc::SharedMemory::TYPE_BASIC, &mem)) { + if (!mVideoHost.SharedMemMgr()->MgrAllocShmem(GMPSharedMem::kGMPFrameData, + aFrameBufferSize, &mem)) { GMP_LOG_ERROR("%s: Failed to get a shared mem buffer for Child! size %u", __FUNCTION__, aFrameBufferSize); return IPC_FAIL(this, "Failed to get a shared mem buffer for Child!"); diff --git a/dom/media/gmp/GMPVideoDecoderParent.h b/dom/media/gmp/GMPVideoDecoderParent.h index 88d98fc529b2..10f92b0d76d8 100644 --- a/dom/media/gmp/GMPVideoDecoderParent.h +++ b/dom/media/gmp/GMPVideoDecoderParent.h @@ -53,9 +53,8 @@ class GMPVideoDecoderParent final : public PGMPVideoDecoderParent, const nsCString& GetDisplayName() const override; // GMPSharedMemManager - bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aMem) override { - return AllocShmem(aSize, aType, aMem); + bool Alloc(size_t aSize, Shmem* aMem) override { + return AllocShmem(aSize, aMem); } void Dealloc(Shmem&& aMem) override { DeallocShmem(aMem); } diff --git a/dom/media/gmp/GMPVideoEncodedFrameImpl.cpp b/dom/media/gmp/GMPVideoEncodedFrameImpl.cpp index 575b9fee80cc..c0ed87df4da6 100644 --- a/dom/media/gmp/GMPVideoEncodedFrameImpl.cpp +++ b/dom/media/gmp/GMPVideoEncodedFrameImpl.cpp @@ -100,9 +100,8 @@ GMPErr GMPVideoEncodedFrameImpl::CreateEmptyFrame(uint32_t aSize) { DestroyBuffer(); } else if (aSize > AllocatedSize()) { DestroyBuffer(); - if (!mHost->SharedMemMgr()->MgrAllocShmem( - GMPSharedMem::kGMPEncodedData, aSize, ipc::SharedMemory::TYPE_BASIC, - &mBuffer) || + if (!mHost->SharedMemMgr()->MgrAllocShmem(GMPSharedMem::kGMPEncodedData, + aSize, &mBuffer) || !Buffer()) { return GMPAllocErr; } @@ -176,9 +175,8 @@ void GMPVideoEncodedFrameImpl::SetAllocatedSize(uint32_t aNewSize) { } ipc::Shmem new_mem; - if (!mHost->SharedMemMgr()->MgrAllocShmem( - GMPSharedMem::kGMPEncodedData, aNewSize, - ipc::SharedMemory::TYPE_BASIC, &new_mem) || + if (!mHost->SharedMemMgr()->MgrAllocShmem(GMPSharedMem::kGMPEncodedData, + aNewSize, &new_mem) || !new_mem.get()) { return; } diff --git a/dom/media/gmp/GMPVideoEncoderChild.cpp b/dom/media/gmp/GMPVideoEncoderChild.cpp index 07bb20c5cf40..19a96b5efedc 100644 --- a/dom/media/gmp/GMPVideoEncoderChild.cpp +++ b/dom/media/gmp/GMPVideoEncoderChild.cpp @@ -172,9 +172,7 @@ mozilla::ipc::IPCResult GMPVideoEncoderChild::RecvEncodingComplete() { return IPC_OK(); } -bool GMPVideoEncoderChild::Alloc(size_t aSize, - Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aMem) { +bool GMPVideoEncoderChild::Alloc(size_t aSize, Shmem* aMem) { MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current()); bool rv; @@ -189,7 +187,7 @@ bool GMPVideoEncoderChild::Alloc(size_t aSize, this, &GMPVideoEncoderChild::RecvEncodingComplete)); } #else - rv = AllocShmem(aSize, aType, aMem); + rv = AllocShmem(aSize, aMem); #endif return rv; } diff --git a/dom/media/gmp/GMPVideoEncoderChild.h b/dom/media/gmp/GMPVideoEncoderChild.h index 18a87c6dbea2..dd3c0fdf370b 100644 --- a/dom/media/gmp/GMPVideoEncoderChild.h +++ b/dom/media/gmp/GMPVideoEncoderChild.h @@ -38,8 +38,7 @@ class GMPVideoEncoderChild : public PGMPVideoEncoderChild, void Error(GMPErr aError) override; // GMPSharedMemManager - bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aMem) override; + bool Alloc(size_t aSize, Shmem* aMem) override; void Dealloc(Shmem&& aMem) override; private: diff --git a/dom/media/gmp/GMPVideoEncoderParent.cpp b/dom/media/gmp/GMPVideoEncoderParent.cpp index 24ac2685db13..21c86ff9ab51 100644 --- a/dom/media/gmp/GMPVideoEncoderParent.cpp +++ b/dom/media/gmp/GMPVideoEncoderParent.cpp @@ -279,9 +279,8 @@ mozilla::ipc::IPCResult GMPVideoEncoderParent::RecvNeedShmem( // This test may be paranoia now that we don't shut down the VideoHost // in ::Shutdown, but doesn't hurt if (!mVideoHost.SharedMemMgr() || - !mVideoHost.SharedMemMgr()->MgrAllocShmem( - GMPSharedMem::kGMPEncodedData, aEncodedBufferSize, - ipc::SharedMemory::TYPE_BASIC, &mem)) { + !mVideoHost.SharedMemMgr()->MgrAllocShmem(GMPSharedMem::kGMPEncodedData, + aEncodedBufferSize, &mem)) { GMP_LOG_ERROR( "%s::%s: Failed to get a shared mem buffer for Child! size %u", __CLASS__, __FUNCTION__, aEncodedBufferSize); diff --git a/dom/media/gmp/GMPVideoEncoderParent.h b/dom/media/gmp/GMPVideoEncoderParent.h index c4707a03b47e..9e2061ae2801 100644 --- a/dom/media/gmp/GMPVideoEncoderParent.h +++ b/dom/media/gmp/GMPVideoEncoderParent.h @@ -51,9 +51,8 @@ class GMPVideoEncoderParent : public GMPVideoEncoderProxy, uint32_t GetPluginId() const override { return mPluginId; } // GMPSharedMemManager - bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aMem) override { - return AllocShmem(aSize, aType, aMem); + bool Alloc(size_t aSize, Shmem* aMem) override { + return AllocShmem(aSize, aMem); } void Dealloc(Shmem&& aMem) override { DeallocShmem(aMem); } diff --git a/dom/media/gmp/GMPVideoPlaneImpl.cpp b/dom/media/gmp/GMPVideoPlaneImpl.cpp index ffc42133089e..6c24b5b4a6b0 100644 --- a/dom/media/gmp/GMPVideoPlaneImpl.cpp +++ b/dom/media/gmp/GMPVideoPlaneImpl.cpp @@ -72,9 +72,8 @@ GMPErr GMPPlaneImpl::MaybeResize(int32_t aNewSize) { } ipc::Shmem new_mem; - if (!mHost->SharedMemMgr()->MgrAllocShmem( - GMPSharedMem::kGMPFrameData, aNewSize, ipc::SharedMemory::TYPE_BASIC, - &new_mem) || + if (!mHost->SharedMemMgr()->MgrAllocShmem(GMPSharedMem::kGMPFrameData, + aNewSize, &new_mem) || !new_mem.get()) { return GMPAllocErr; } diff --git a/dom/media/ipc/RemoteDecoderManagerChild.h b/dom/media/ipc/RemoteDecoderManagerChild.h index 9c5804a7bb29..f4960cb3ac5d 100644 --- a/dom/media/ipc/RemoteDecoderManagerChild.h +++ b/dom/media/ipc/RemoteDecoderManagerChild.h @@ -62,16 +62,11 @@ class RemoteDecoderManagerChild final void DeallocateSurfaceDescriptor( const SurfaceDescriptorGPUVideo& aSD) override; - bool AllocShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) override { - return PRemoteDecoderManagerChild::AllocShmem(aSize, aShmType, aShmem); + bool AllocShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override { + return PRemoteDecoderManagerChild::AllocShmem(aSize, aShmem); } - bool AllocUnsafeShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) override { - return PRemoteDecoderManagerChild::AllocUnsafeShmem(aSize, aShmType, - aShmem); + bool AllocUnsafeShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override { + return PRemoteDecoderManagerChild::AllocUnsafeShmem(aSize, aShmem); } // Can be called from any thread, dispatches the request to the IPDL thread diff --git a/dom/media/ipc/RemoteDecoderManagerParent.cpp b/dom/media/ipc/RemoteDecoderManagerParent.cpp index ae52a891d952..58b6a07f781b 100644 --- a/dom/media/ipc/RemoteDecoderManagerParent.cpp +++ b/dom/media/ipc/RemoteDecoderManagerParent.cpp @@ -272,8 +272,7 @@ mozilla::ipc::IPCResult RemoteDecoderManagerParent::RecvReadback( size_t length = ImageDataSerializer::ComputeRGBBufferSize(size, format); Shmem buffer; - if (!length || - !AllocShmem(length, Shmem::SharedMemory::TYPE_BASIC, &buffer)) { + if (!length || !AllocShmem(length, &buffer)) { *aResult = null_t(); return IPC_OK(); } diff --git a/dom/media/systemservices/ShmemPool.h b/dom/media/systemservices/ShmemPool.h index 4a08f0892b63..e62ccff24a9c 100644 --- a/dom/media/systemservices/ShmemPool.h +++ b/dom/media/systemservices/ShmemPool.h @@ -162,11 +162,9 @@ class ShmemPool final { bool AllocateShmem(T* aInstance, size_t aSize, ShmemBuffer& aRes, AllocationPolicy aPolicy) { return (aPolicy == AllocationPolicy::Default && - aInstance->AllocShmem(aSize, ipc::SharedMemory::TYPE_BASIC, - &aRes.mShmem)) || + aInstance->AllocShmem(aSize, &aRes.mShmem)) || (aPolicy == AllocationPolicy::Unsafe && - aInstance->AllocUnsafeShmem(aSize, ipc::SharedMemory::TYPE_BASIC, - &aRes.mShmem)); + aInstance->AllocUnsafeShmem(aSize, &aRes.mShmem)); } const PoolType mPoolType; Mutex mMutex MOZ_UNANNOTATED; diff --git a/dom/webgpu/Device.cpp b/dom/webgpu/Device.cpp index d87b1990a594..3f9e7b53d13b 100644 --- a/dom/webgpu/Device.cpp +++ b/dom/webgpu/Device.cpp @@ -138,8 +138,7 @@ already_AddRefed Device::CreateBuffer( const auto& size = checked.value(); // TODO: use `ShmemPool`? - if (!mBridge->AllocShmem(size, ipc::Shmem::SharedMemory::TYPE_BASIC, - &shmem)) { + if (!mBridge->AllocShmem(size, &shmem)) { aRv.ThrowAbortError( nsPrintfCString("Unable to allocate shmem of size %" PRIuPTR, size)); return nullptr; diff --git a/dom/webgpu/Queue.cpp b/dom/webgpu/Queue.cpp index 94e8a4b94f98..d0547839eeea 100644 --- a/dom/webgpu/Queue.cpp +++ b/dom/webgpu/Queue.cpp @@ -71,8 +71,7 @@ void Queue::WriteBuffer(const Buffer& aBuffer, uint64_t aBufferOffset, } ipc::Shmem shmem; - if (!mBridge->AllocShmem(size, ipc::Shmem::SharedMemory::TYPE_BASIC, - &shmem)) { + if (!mBridge->AllocShmem(size, &shmem)) { aRv.ThrowAbortError( nsPrintfCString("Unable to allocate shmem of size %" PRIuPTR, size)); return; @@ -124,8 +123,7 @@ void Queue::WriteTexture(const dom::GPUImageCopyTexture& aDestination, const auto size = checkedSize.value(); ipc::Shmem shmem; - if (!mBridge->AllocShmem(size, ipc::Shmem::SharedMemory::TYPE_BASIC, - &shmem)) { + if (!mBridge->AllocShmem(size, &shmem)) { aRv.ThrowAbortError( nsPrintfCString("Unable to allocate shmem of size %" PRIuPTR, size)); return; diff --git a/dom/webgpu/ipc/WebGPUParent.cpp b/dom/webgpu/ipc/WebGPUParent.cpp index 241d2d74f319..b1a4605c9326 100644 --- a/dom/webgpu/ipc/WebGPUParent.cpp +++ b/dom/webgpu/ipc/WebGPUParent.cpp @@ -717,7 +717,7 @@ ipc::IPCResult WebGPUParent::GetFrontBufferSnapshot( aSize.width * BytesPerPixel(data->mTextureHost->GetFormat()); uint32_t len = data->mRowCount * stride; Shmem shmem; - if (!AllocShmem(len, ipc::Shmem::SharedMemory::TYPE_BASIC, &shmem)) { + if (!AllocShmem(len, &shmem)) { return IPC_OK(); } diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index c4526925f77a..80f20713d54f 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -1197,8 +1197,7 @@ struct IPDLParamTraits { paramType&& aParam) { Shmem shmem; if (aParam.mSize.IsEmpty() || - !aActor->AllocShmem(aParam.mRecording.mLen, SharedMemory::TYPE_BASIC, - &shmem)) { + !aActor->AllocShmem(aParam.mRecording.mLen, &shmem)) { WriteParam(aWriter, gfx::IntSize(0, 0)); return; } diff --git a/gfx/layers/BufferTexture.cpp b/gfx/layers/BufferTexture.cpp index 57488fb78a74..3141ea84e017 100644 --- a/gfx/layers/BufferTexture.cpp +++ b/gfx/layers/BufferTexture.cpp @@ -130,7 +130,7 @@ BufferTextureData* BufferTextureData::CreateInternal( return new MemoryTextureData(aDesc, aMoz2DBackend, buffer, aBufferSize); } else { ipc::Shmem shm; - if (!aAllocator->AllocUnsafeShmem(aBufferSize, OptimalShmemType(), &shm)) { + if (!aAllocator->AllocUnsafeShmem(aBufferSize, &shm)) { return nullptr; } @@ -491,7 +491,7 @@ ShmemTextureData* ShmemTextureData::Create(gfx::IntSize aSize, } mozilla::ipc::Shmem shm; - if (!aAllocator->AllocUnsafeShmem(bufSize, OptimalShmemType(), &shm)) { + if (!aAllocator->AllocUnsafeShmem(bufSize, &shm)) { return nullptr; } diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index 60579eab919c..2d857eced657 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -577,18 +577,14 @@ void CompositorBridgeChild::EndCanvasTransaction() { } } -bool CompositorBridgeChild::AllocUnsafeShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool CompositorBridgeChild::AllocUnsafeShmem(size_t aSize, ipc::Shmem* aShmem) { ShmemAllocated(this); - return PCompositorBridgeChild::AllocUnsafeShmem(aSize, aType, aShmem); + return PCompositorBridgeChild::AllocUnsafeShmem(aSize, aShmem); } -bool CompositorBridgeChild::AllocShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool CompositorBridgeChild::AllocShmem(size_t aSize, ipc::Shmem* aShmem) { ShmemAllocated(this); - return PCompositorBridgeChild::AllocShmem(aSize, aType, aShmem); + return PCompositorBridgeChild::AllocShmem(aSize, aShmem); } bool CompositorBridgeChild::DeallocShmem(ipc::Shmem& aShmem) { diff --git a/gfx/layers/ipc/CompositorBridgeChild.h b/gfx/layers/ipc/CompositorBridgeChild.h index eff6f6e5f156..7e005aab3671 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.h +++ b/gfx/layers/ipc/CompositorBridgeChild.h @@ -152,12 +152,8 @@ class CompositorBridgeChild final : public PCompositorBridgeChild, base::ProcessId GetParentPid() const override { return OtherPid(); } - bool AllocUnsafeShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) override; - bool AllocShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) override; + bool AllocUnsafeShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override; + bool AllocShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override; bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override; PCompositorWidgetChild* AllocPCompositorWidgetChild( diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index d9a162d8b416..22a71c1d3ed6 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -149,16 +149,13 @@ void CompositorBridgeParentBase::SendAsyncMessage( Unused << SendParentAsyncMessages(aMessage); } -bool CompositorBridgeParentBase::AllocShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { - return PCompositorBridgeParent::AllocShmem(aSize, aType, aShmem); +bool CompositorBridgeParentBase::AllocShmem(size_t aSize, ipc::Shmem* aShmem) { + return PCompositorBridgeParent::AllocShmem(aSize, aShmem); } -bool CompositorBridgeParentBase::AllocUnsafeShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { - return PCompositorBridgeParent::AllocUnsafeShmem(aSize, aType, aShmem); +bool CompositorBridgeParentBase::AllocUnsafeShmem(size_t aSize, + ipc::Shmem* aShmem) { + return PCompositorBridgeParent::AllocUnsafeShmem(aSize, aShmem); } bool CompositorBridgeParentBase::DeallocShmem(ipc::Shmem& aShmem) { @@ -2115,7 +2112,7 @@ Maybe CompositorBridgeParent::WrapCollectedFrames( } Shmem shmem; - if (!AllocShmem(totalLength, SharedMemory::TYPE_BASIC, &shmem)) { + if (!AllocShmem(totalLength, &shmem)) { return Nothing(); } diff --git a/gfx/layers/ipc/CompositorBridgeParent.h b/gfx/layers/ipc/CompositorBridgeParent.h index bf4e9306d5ca..f28360249eb6 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.h +++ b/gfx/layers/ipc/CompositorBridgeParent.h @@ -148,12 +148,8 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, const nsTArray& aMessage) override; // IShmemAllocator - bool AllocShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aType, - mozilla::ipc::Shmem* aShmem) override; - bool AllocUnsafeShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aType, - mozilla::ipc::Shmem* aShmem) override; + bool AllocShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override; + bool AllocUnsafeShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override; bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override; NS_IMETHOD_(MozExternalRefCountType) AddRef() override { diff --git a/gfx/layers/ipc/ISurfaceAllocator.cpp b/gfx/layers/ipc/ISurfaceAllocator.cpp index f3002d3e2361..7baca7a9b667 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.cpp +++ b/gfx/layers/ipc/ISurfaceAllocator.cpp @@ -18,10 +18,6 @@ NS_IMPL_ISUPPORTS(GfxMemoryImageReporter, nsIMemoryReporter) mozilla::Atomic GfxMemoryImageReporter::sAmount(0); -mozilla::ipc::SharedMemory::SharedMemoryType OptimalShmemType() { - return ipc::SharedMemory::SharedMemoryType::TYPE_BASIC; -} - void HostIPCAllocator::SendPendingAsyncMessages() { if (mPendingAsyncMessage.empty()) { return; @@ -102,8 +98,7 @@ bool FixedSizeSmallShmemSectionAllocator::AllocShmemSection( if (!aShmemSection->shmem().IsWritable()) { ipc::Shmem tmp; - if (!mShmProvider->AllocUnsafeShmem(sShmemPageSize, OptimalShmemType(), - &tmp)) { + if (!mShmProvider->AllocUnsafeShmem(sShmemPageSize, &tmp)) { return false; } diff --git a/gfx/layers/ipc/ISurfaceAllocator.h b/gfx/layers/ipc/ISurfaceAllocator.h index 2dcdf3d5db10..ea69b0fc2cb2 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.h +++ b/gfx/layers/ipc/ISurfaceAllocator.h @@ -52,8 +52,6 @@ enum BufferCapabilities { class SurfaceDescriptor; -mozilla::ipc::SharedMemory::SharedMemoryType OptimalShmemType(); - /** * An interface used to create and destroy surfaces that are shared with the * Compositor process (using shmem, or other platform specific memory) diff --git a/gfx/layers/ipc/ImageBridgeChild.cpp b/gfx/layers/ipc/ImageBridgeChild.cpp index 1f5348321b23..f88f387fedf6 100644 --- a/gfx/layers/ipc/ImageBridgeChild.cpp +++ b/gfx/layers/ipc/ImageBridgeChild.cpp @@ -677,36 +677,31 @@ RefPtr ImageBridgeChild::CreateImageClientNow( return client; } -bool ImageBridgeChild::AllocUnsafeShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool ImageBridgeChild::AllocUnsafeShmem(size_t aSize, ipc::Shmem* aShmem) { if (!InImageBridgeChildThread()) { - return DispatchAllocShmemInternal(aSize, aType, aShmem, + return DispatchAllocShmemInternal(aSize, aShmem, true); // true: unsafe } if (!CanSend()) { return false; } - return PImageBridgeChild::AllocUnsafeShmem(aSize, aType, aShmem); + return PImageBridgeChild::AllocUnsafeShmem(aSize, aShmem); } -bool ImageBridgeChild::AllocShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool ImageBridgeChild::AllocShmem(size_t aSize, ipc::Shmem* aShmem) { if (!InImageBridgeChildThread()) { - return DispatchAllocShmemInternal(aSize, aType, aShmem, + return DispatchAllocShmemInternal(aSize, aShmem, false); // false: unsafe } if (!CanSend()) { return false; } - return PImageBridgeChild::AllocShmem(aSize, aType, aShmem); + return PImageBridgeChild::AllocShmem(aSize, aShmem); } void ImageBridgeChild::ProxyAllocShmemNow(SynchronousTask* aTask, size_t aSize, - SharedMemory::SharedMemoryType aType, ipc::Shmem* aShmem, bool aUnsafe, bool* aSuccess) { AutoCompleteTask complete(aTask); @@ -717,22 +712,22 @@ void ImageBridgeChild::ProxyAllocShmemNow(SynchronousTask* aTask, size_t aSize, bool ok = false; if (aUnsafe) { - ok = AllocUnsafeShmem(aSize, aType, aShmem); + ok = AllocUnsafeShmem(aSize, aShmem); } else { - ok = AllocShmem(aSize, aType, aShmem); + ok = AllocShmem(aSize, aShmem); } *aSuccess = ok; } -bool ImageBridgeChild::DispatchAllocShmemInternal( - size_t aSize, SharedMemory::SharedMemoryType aType, ipc::Shmem* aShmem, - bool aUnsafe) { +bool ImageBridgeChild::DispatchAllocShmemInternal(size_t aSize, + ipc::Shmem* aShmem, + bool aUnsafe) { SynchronousTask task("AllocatorProxy alloc"); bool success = false; RefPtr runnable = WrapRunnable( RefPtr(this), &ImageBridgeChild::ProxyAllocShmemNow, - &task, aSize, aType, aShmem, aUnsafe, &success); + &task, aSize, aShmem, aUnsafe, &success); GetThread()->Dispatch(runnable.forget()); task.Wait(); diff --git a/gfx/layers/ipc/ImageBridgeChild.h b/gfx/layers/ipc/ImageBridgeChild.h index e4583e9c313d..13833de78e46 100644 --- a/gfx/layers/ipc/ImageBridgeChild.h +++ b/gfx/layers/ipc/ImageBridgeChild.h @@ -223,7 +223,6 @@ class ImageBridgeChild final : public PImageBridgeChild, ImageContainer* aContainer); void ProxyAllocShmemNow(SynchronousTask* aTask, size_t aSize, - SharedMemory::SharedMemoryType aType, mozilla::ipc::Shmem* aShmem, bool aUnsafe, bool* aSuccess); void ProxyDeallocShmemNow(SynchronousTask* aTask, mozilla::ipc::Shmem* aShmem, @@ -288,12 +287,8 @@ class ImageBridgeChild final : public PImageBridgeChild, * If used outside the ImageBridgeChild thread, it will proxy a synchronous * call on the ImageBridgeChild thread. */ - bool AllocUnsafeShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) override; - bool AllocShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) override; + bool AllocUnsafeShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override; + bool AllocShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override; /** * See ISurfaceAllocator.h @@ -321,9 +316,7 @@ class ImageBridgeChild final : public PImageBridgeChild, protected: explicit ImageBridgeChild(uint32_t aNamespace); - bool DispatchAllocShmemInternal(size_t aSize, - SharedMemory::SharedMemoryType aType, - Shmem* aShmem, bool aUnsafe); + bool DispatchAllocShmemInternal(size_t aSize, Shmem* aShmem, bool aUnsafe); void Bind(Endpoint&& aEndpoint); void BindSameProcess(RefPtr aParent); diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index dc8c9797a9ee..6d22ba6fe665 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -381,22 +381,18 @@ already_AddRefed ImageBridgeParent::GetInstance( return bridge.forget(); } -bool ImageBridgeParent::AllocShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool ImageBridgeParent::AllocShmem(size_t aSize, ipc::Shmem* aShmem) { if (mClosed) { return false; } - return PImageBridgeParent::AllocShmem(aSize, aType, aShmem); + return PImageBridgeParent::AllocShmem(aSize, aShmem); } -bool ImageBridgeParent::AllocUnsafeShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool ImageBridgeParent::AllocUnsafeShmem(size_t aSize, ipc::Shmem* aShmem) { if (mClosed) { return false; } - return PImageBridgeParent::AllocUnsafeShmem(aSize, aType, aShmem); + return PImageBridgeParent::AllocUnsafeShmem(aSize, aShmem); } bool ImageBridgeParent::DeallocShmem(ipc::Shmem& aShmem) { diff --git a/gfx/layers/ipc/ImageBridgeParent.h b/gfx/layers/ipc/ImageBridgeParent.h index 25f38e780d53..055ec427957d 100644 --- a/gfx/layers/ipc/ImageBridgeParent.h +++ b/gfx/layers/ipc/ImageBridgeParent.h @@ -102,11 +102,9 @@ class ImageBridgeParent final : public PImageBridgeParent, // IShmemAllocator - bool AllocShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; + bool AllocShmem(size_t aSize, ipc::Shmem* aShmem) override; - bool AllocUnsafeShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; + bool AllocUnsafeShmem(size_t aSize, ipc::Shmem* aShmem) override; bool DeallocShmem(ipc::Shmem& aShmem) override; diff --git a/gfx/layers/ipc/RefCountedShmem.cpp b/gfx/layers/ipc/RefCountedShmem.cpp index 205fa990fdb9..8eec82dc9ae3 100644 --- a/gfx/layers/ipc/RefCountedShmem.cpp +++ b/gfx/layers/ipc/RefCountedShmem.cpp @@ -76,9 +76,8 @@ int32_t RefCountedShm::Release(const RefCountedShmem& aShm) { bool RefCountedShm::Alloc(mozilla::ipc::IProtocol* aAllocator, size_t aSize, RefCountedShmem& aShm) { MOZ_ASSERT(!IsValid(aShm)); - auto shmType = ipc::SharedMemory::SharedMemoryType::TYPE_BASIC; auto size = aSize + SHM_REFCOUNT_HEADER_SIZE; - if (!aAllocator->AllocUnsafeShmem(size, shmType, &aShm.buffer())) { + if (!aAllocator->AllocUnsafeShmem(size, &aShm.buffer())) { return false; } return true; diff --git a/gfx/layers/ipc/UiCompositorControllerParent.cpp b/gfx/layers/ipc/UiCompositorControllerParent.cpp index eb7f37189de4..6ec6d2209083 100644 --- a/gfx/layers/ipc/UiCompositorControllerParent.cpp +++ b/gfx/layers/ipc/UiCompositorControllerParent.cpp @@ -186,7 +186,7 @@ void UiCompositorControllerParent::ToolbarAnimatorMessageFromCompositor( bool UiCompositorControllerParent::AllocPixelBuffer(const int32_t aSize, ipc::Shmem* aMem) { MOZ_ASSERT(aSize > 0); - return AllocShmem(aSize, ipc::SharedMemory::TYPE_BASIC, aMem); + return AllocShmem(aSize, aMem); } void UiCompositorControllerParent::NotifyLayersUpdated() { diff --git a/gfx/layers/ipc/VideoBridgeChild.cpp b/gfx/layers/ipc/VideoBridgeChild.cpp index acffd0ff1375..2041f1086cd1 100644 --- a/gfx/layers/ipc/VideoBridgeChild.cpp +++ b/gfx/layers/ipc/VideoBridgeChild.cpp @@ -57,30 +57,24 @@ VideoBridgeChild::~VideoBridgeChild() = default; VideoBridgeChild* VideoBridgeChild::GetSingleton() { return sVideoBridge; } -bool VideoBridgeChild::AllocUnsafeShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool VideoBridgeChild::AllocUnsafeShmem(size_t aSize, ipc::Shmem* aShmem) { if (!mThread->IsOnCurrentThread()) { - return DispatchAllocShmemInternal(aSize, aType, aShmem, - true); // true: unsafe + return DispatchAllocShmemInternal(aSize, aShmem, true); // true: unsafe } if (!CanSend()) { return false; } - return PVideoBridgeChild::AllocUnsafeShmem(aSize, aType, aShmem); + return PVideoBridgeChild::AllocUnsafeShmem(aSize, aShmem); } -bool VideoBridgeChild::AllocShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool VideoBridgeChild::AllocShmem(size_t aSize, ipc::Shmem* aShmem) { MOZ_ASSERT(CanSend()); - return PVideoBridgeChild::AllocShmem(aSize, aType, aShmem); + return PVideoBridgeChild::AllocShmem(aSize, aShmem); } void VideoBridgeChild::ProxyAllocShmemNow(SynchronousTask* aTask, size_t aSize, - SharedMemory::SharedMemoryType aType, ipc::Shmem* aShmem, bool aUnsafe, bool* aSuccess) { AutoCompleteTask complete(aTask); @@ -91,22 +85,22 @@ void VideoBridgeChild::ProxyAllocShmemNow(SynchronousTask* aTask, size_t aSize, bool ok = false; if (aUnsafe) { - ok = AllocUnsafeShmem(aSize, aType, aShmem); + ok = AllocUnsafeShmem(aSize, aShmem); } else { - ok = AllocShmem(aSize, aType, aShmem); + ok = AllocShmem(aSize, aShmem); } *aSuccess = ok; } -bool VideoBridgeChild::DispatchAllocShmemInternal( - size_t aSize, SharedMemory::SharedMemoryType aType, ipc::Shmem* aShmem, - bool aUnsafe) { +bool VideoBridgeChild::DispatchAllocShmemInternal(size_t aSize, + ipc::Shmem* aShmem, + bool aUnsafe) { SynchronousTask task("AllocatorProxy alloc"); bool success = false; RefPtr runnable = WrapRunnable( RefPtr(this), &VideoBridgeChild::ProxyAllocShmemNow, - &task, aSize, aType, aShmem, aUnsafe, &success); + &task, aSize, aShmem, aUnsafe, &success); GetThread()->Dispatch(runnable.forget()); task.Wait(); diff --git a/gfx/layers/ipc/VideoBridgeChild.h b/gfx/layers/ipc/VideoBridgeChild.h index a513597eff35..eff2ac46b255 100644 --- a/gfx/layers/ipc/VideoBridgeChild.h +++ b/gfx/layers/ipc/VideoBridgeChild.h @@ -39,12 +39,8 @@ class VideoBridgeChild final : public PVideoBridgeChild, void ActorDealloc() override; // ISurfaceAllocator - bool AllocUnsafeShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) override; - bool AllocShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) override; + bool AllocUnsafeShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override; + bool AllocShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) override; bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override; // TextureForwarder @@ -69,11 +65,9 @@ class VideoBridgeChild final : public PVideoBridgeChild, protected: void HandleFatalError(const char* aMsg) const override; - bool DispatchAllocShmemInternal(size_t aSize, - SharedMemory::SharedMemoryType aType, - mozilla::ipc::Shmem* aShmem, bool aUnsafe); + bool DispatchAllocShmemInternal(size_t aSize, mozilla::ipc::Shmem* aShmem, + bool aUnsafe); void ProxyAllocShmemNow(SynchronousTask* aTask, size_t aSize, - SharedMemory::SharedMemoryType aType, mozilla::ipc::Shmem* aShmem, bool aUnsafe, bool* aSuccess); void ProxyDeallocShmemNow(SynchronousTask* aTask, mozilla::ipc::Shmem* aShmem, diff --git a/gfx/layers/ipc/VideoBridgeParent.cpp b/gfx/layers/ipc/VideoBridgeParent.cpp index 954f9bca1801..e9e2509c4f21 100644 --- a/gfx/layers/ipc/VideoBridgeParent.cpp +++ b/gfx/layers/ipc/VideoBridgeParent.cpp @@ -134,22 +134,18 @@ void VideoBridgeParent::SendAsyncMessage( MOZ_ASSERT(false, "AsyncMessages not supported"); } -bool VideoBridgeParent::AllocShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool VideoBridgeParent::AllocShmem(size_t aSize, ipc::Shmem* aShmem) { if (mClosed) { return false; } - return PVideoBridgeParent::AllocShmem(aSize, aType, aShmem); + return PVideoBridgeParent::AllocShmem(aSize, aShmem); } -bool VideoBridgeParent::AllocUnsafeShmem( - size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) { +bool VideoBridgeParent::AllocUnsafeShmem(size_t aSize, ipc::Shmem* aShmem) { if (mClosed) { return false; } - return PVideoBridgeParent::AllocUnsafeShmem(aSize, aType, aShmem); + return PVideoBridgeParent::AllocUnsafeShmem(aSize, aShmem); } bool VideoBridgeParent::DeallocShmem(ipc::Shmem& aShmem) { diff --git a/gfx/layers/ipc/VideoBridgeParent.h b/gfx/layers/ipc/VideoBridgeParent.h index ddfbd0528799..e0ac1335db64 100644 --- a/gfx/layers/ipc/VideoBridgeParent.h +++ b/gfx/layers/ipc/VideoBridgeParent.h @@ -53,11 +53,9 @@ class VideoBridgeParent final : public PVideoBridgeParent, bool IPCOpen() const override { return !mClosed; } // IShmemAllocator - bool AllocShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; + bool AllocShmem(size_t aSize, ipc::Shmem* aShmem) override; - bool AllocUnsafeShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; + bool AllocUnsafeShmem(size_t aSize, ipc::Shmem* aShmem) override; bool DeallocShmem(ipc::Shmem& aShmem) override; diff --git a/gfx/layers/wr/IpcResourceUpdateQueue.cpp b/gfx/layers/wr/IpcResourceUpdateQueue.cpp index 55b9dcd16e00..9958a70f1553 100644 --- a/gfx/layers/wr/IpcResourceUpdateQueue.cpp +++ b/gfx/layers/wr/IpcResourceUpdateQueue.cpp @@ -127,8 +127,7 @@ bool ShmSegmentsWriter::AllocChunk() { layers::OffsetRange ShmSegmentsWriter::AllocLargeChunk(size_t aSize) { ipc::Shmem shm; - auto shmType = ipc::SharedMemory::SharedMemoryType::TYPE_BASIC; - if (!mShmAllocator->AllocShmem(aSize, shmType, &shm)) { + if (!mShmAllocator->AllocShmem(aSize, &shm)) { gfxCriticalNote << "ShmSegmentsWriter failed to allocate large chunk of size " << aSize; MOZ_ASSERT(false, "ShmSegmentsWriter fails to allocate large chunk"); diff --git a/gfx/thebes/gfxBaseSharedMemorySurface.h b/gfx/thebes/gfxBaseSharedMemorySurface.h index 77a7a2c36366..bf211edab51c 100644 --- a/gfx/thebes/gfxBaseSharedMemorySurface.h +++ b/gfx/thebes/gfxBaseSharedMemorySurface.h @@ -52,11 +52,10 @@ class gfxBaseSharedMemorySurface : public Base { * by this function. */ template - static already_AddRefed Create( - ShmemAllocator* aAllocator, const mozilla::gfx::IntSize& aSize, - gfxImageFormat aFormat, - SharedMemory::SharedMemoryType aShmType = SharedMemory::TYPE_BASIC) { - return Create(aAllocator, aSize, aFormat, aShmType); + static already_AddRefed Create(ShmemAllocator* aAllocator, + const mozilla::gfx::IntSize& aSize, + gfxImageFormat aFormat) { + return Create(aAllocator, aSize, aFormat); } /** @@ -79,11 +78,10 @@ class gfxBaseSharedMemorySurface : public Base { } template - static already_AddRefed CreateUnsafe( - ShmemAllocator* aAllocator, const mozilla::gfx::IntSize& aSize, - gfxImageFormat aFormat, - SharedMemory::SharedMemoryType aShmType = SharedMemory::TYPE_BASIC) { - return Create(aAllocator, aSize, aFormat, aShmType); + static already_AddRefed CreateUnsafe(ShmemAllocator* aAllocator, + const mozilla::gfx::IntSize& aSize, + gfxImageFormat aFormat) { + return Create(aAllocator, aSize, aFormat); } Shmem& GetShmem() { return mShmem; } @@ -136,17 +134,16 @@ class gfxBaseSharedMemorySurface : public Base { template static already_AddRefed Create(ShmemAllocator* aAllocator, const mozilla::gfx::IntSize& aSize, - gfxImageFormat aFormat, - SharedMemory::SharedMemoryType aShmType) { + gfxImageFormat aFormat) { if (!mozilla::gfx::Factory::CheckSurfaceSize(aSize)) return nullptr; Shmem shmem; long stride = gfxImageSurface::ComputeStride(aSize, aFormat); size_t size = GetAlignedSize(aSize, stride); if (!Unsafe) { - if (!aAllocator->AllocShmem(size, aShmType, &shmem)) return nullptr; + if (!aAllocator->AllocShmem(size, &shmem)) return nullptr; } else { - if (!aAllocator->AllocUnsafeShmem(size, aShmType, &shmem)) return nullptr; + if (!aAllocator->AllocUnsafeShmem(size, &shmem)) return nullptr; } RefPtr s = new Sub(aSize, stride, aFormat, shmem); diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp index 0154f48fb37c..77ce6045b621 100644 --- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -326,10 +326,9 @@ void IProtocol::Unregister(int32_t aId) { return mToplevel->Unregister(aId); } -Shmem::SharedMemory* IProtocol::CreateSharedMemory( - size_t aSize, SharedMemory::SharedMemoryType aType, bool aUnsafe, - int32_t* aId) { - return mToplevel->CreateSharedMemory(aSize, aType, aUnsafe, aId); +Shmem::SharedMemory* IProtocol::CreateSharedMemory(size_t aSize, bool aUnsafe, + int32_t* aId) { + return mToplevel->CreateSharedMemory(aSize, aUnsafe, aId); } Shmem::SharedMemory* IProtocol::LookupSharedMemory(int32_t aId) { return mToplevel->LookupSharedMemory(aId); @@ -403,9 +402,7 @@ void IProtocol::HandleFatalError(const char* aErrorMsg) const { mozilla::ipc::FatalError(aErrorMsg, mSide == ParentSide); } -bool IProtocol::AllocShmem(size_t aSize, - Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aOutMem) { +bool IProtocol::AllocShmem(size_t aSize, Shmem* aOutMem) { if (!CanSend()) { NS_WARNING( "Shmem not allocated. Cannot communicate with the other actor."); @@ -413,7 +410,7 @@ bool IProtocol::AllocShmem(size_t aSize, } Shmem::id_t id; - Shmem::SharedMemory* rawmem(CreateSharedMemory(aSize, aType, false, &id)); + Shmem::SharedMemory* rawmem(CreateSharedMemory(aSize, false, &id)); if (!rawmem) { return false; } @@ -422,9 +419,7 @@ bool IProtocol::AllocShmem(size_t aSize, return true; } -bool IProtocol::AllocUnsafeShmem(size_t aSize, - Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aOutMem) { +bool IProtocol::AllocUnsafeShmem(size_t aSize, Shmem* aOutMem) { if (!CanSend()) { NS_WARNING( "Shmem not allocated. Cannot communicate with the other actor."); @@ -432,7 +427,7 @@ bool IProtocol::AllocUnsafeShmem(size_t aSize, } Shmem::id_t id; - Shmem::SharedMemory* rawmem(CreateSharedMemory(aSize, aType, true, &id)); + Shmem::SharedMemory* rawmem(CreateSharedMemory(aSize, true, &id)); if (!rawmem) { return false; } @@ -675,11 +670,11 @@ void IToplevelProtocol::Unregister(int32_t aId) { mActorMap.Remove(aId); } -Shmem::SharedMemory* IToplevelProtocol::CreateSharedMemory( - size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, bool aUnsafe, - Shmem::id_t* aId) { +Shmem::SharedMemory* IToplevelProtocol::CreateSharedMemory(size_t aSize, + bool aUnsafe, + Shmem::id_t* aId) { RefPtr segment( - Shmem::Alloc(Shmem::PrivateIPDLCaller(), aSize, aType, aUnsafe)); + Shmem::Alloc(Shmem::PrivateIPDLCaller(), aSize, aUnsafe)); if (!segment) { return nullptr; } diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index 49c76f021b9c..0d0e21b0cf1d 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -198,9 +198,8 @@ class IProtocol : public HasResultCodes { IProtocol* Lookup(int32_t aId); void Unregister(int32_t aId); - Shmem::SharedMemory* CreateSharedMemory(size_t aSize, - SharedMemory::SharedMemoryType aType, - bool aUnsafe, int32_t* aId); + Shmem::SharedMemory* CreateSharedMemory(size_t aSize, bool aUnsafe, + int32_t* aId); Shmem::SharedMemory* LookupSharedMemory(int32_t aId); bool IsTrackingSharedMemory(Shmem::SharedMemory* aSegment); bool DestroySharedMemory(Shmem& aShmem); @@ -243,11 +242,8 @@ class IProtocol : public HasResultCodes { UniquePtr& aReply) = 0; virtual Result OnCallReceived(const Message& aMessage, UniquePtr& aReply) = 0; - bool AllocShmem(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aOutMem); - bool AllocUnsafeShmem(size_t aSize, - Shmem::SharedMemory::SharedMemoryType aType, - Shmem* aOutMem); + bool AllocShmem(size_t aSize, Shmem* aOutMem); + bool AllocUnsafeShmem(size_t aSize, Shmem* aOutMem); bool DeallocShmem(Shmem& aMem); void FatalError(const char* const aErrorMsg) const; @@ -401,9 +397,8 @@ class IToplevelProtocol : public IProtocol { IProtocol* Lookup(int32_t aId); void Unregister(int32_t aId); - Shmem::SharedMemory* CreateSharedMemory(size_t aSize, - SharedMemory::SharedMemoryType aType, - bool aUnsafe, int32_t* aId); + Shmem::SharedMemory* CreateSharedMemory(size_t aSize, bool aUnsafe, + int32_t* aId); Shmem::SharedMemory* LookupSharedMemory(int32_t aId); bool IsTrackingSharedMemory(Shmem::SharedMemory* aSegment); bool DestroySharedMemory(Shmem& aShmem); @@ -509,25 +504,19 @@ class IToplevelProtocol : public IProtocol { class IShmemAllocator { public: - virtual bool AllocShmem(size_t aSize, - mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) = 0; - virtual bool AllocUnsafeShmem( - size_t aSize, mozilla::ipc::SharedMemory::SharedMemoryType aShmType, - mozilla::ipc::Shmem* aShmem) = 0; + virtual bool AllocShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) = 0; + virtual bool AllocUnsafeShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) = 0; virtual bool DeallocShmem(mozilla::ipc::Shmem& aShmem) = 0; }; #define FORWARD_SHMEM_ALLOCATOR_TO(aImplClass) \ - virtual bool AllocShmem( \ - size_t aSize, mozilla::ipc::SharedMemory::SharedMemoryType aShmType, \ - mozilla::ipc::Shmem* aShmem) override { \ - return aImplClass::AllocShmem(aSize, aShmType, aShmem); \ + virtual bool AllocShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) \ + override { \ + return aImplClass::AllocShmem(aSize, aShmem); \ } \ - virtual bool AllocUnsafeShmem( \ - size_t aSize, mozilla::ipc::SharedMemory::SharedMemoryType aShmType, \ - mozilla::ipc::Shmem* aShmem) override { \ - return aImplClass::AllocUnsafeShmem(aSize, aShmType, aShmem); \ + virtual bool AllocUnsafeShmem(size_t aSize, mozilla::ipc::Shmem* aShmem) \ + override { \ + return aImplClass::AllocUnsafeShmem(aSize, aShmem); \ } \ virtual bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override { \ return aImplClass::DeallocShmem(aShmem); \ diff --git a/ipc/glue/SharedMemory.h b/ipc/glue/SharedMemory.h index d9d40806f5a6..820a1d895484 100644 --- a/ipc/glue/SharedMemory.h +++ b/ipc/glue/SharedMemory.h @@ -38,8 +38,6 @@ class SharedMemory { } public: - enum SharedMemoryType { TYPE_BASIC, TYPE_UNKNOWN }; - enum OpenRights { RightsReadOnly = RightsRead, RightsReadWrite = RightsRead | RightsWrite, @@ -55,8 +53,6 @@ class SharedMemory { virtual void CloseHandle() = 0; - virtual SharedMemoryType Type() const = 0; - virtual bool WriteHandle(IPC::MessageWriter* aWriter) = 0; virtual bool ReadHandle(IPC::MessageReader* aReader) = 0; diff --git a/ipc/glue/SharedMemoryBasic_android.h b/ipc/glue/SharedMemoryBasic_android.h index 75d1852070fe..0b9114e2aefd 100644 --- a/ipc/glue/SharedMemoryBasic_android.h +++ b/ipc/glue/SharedMemoryBasic_android.h @@ -45,8 +45,6 @@ class SharedMemoryBasic final #endif } - virtual SharedMemoryType Type() const override { return TYPE_BASIC; } - static Handle NULLHandle() { return Handle(); } static void* FindFreeAddressSpace(size_t aSize); diff --git a/ipc/glue/SharedMemoryBasic_chromium.h b/ipc/glue/SharedMemoryBasic_chromium.h index c4074c249318..c48898c47da4 100644 --- a/ipc/glue/SharedMemoryBasic_chromium.h +++ b/ipc/glue/SharedMemoryBasic_chromium.h @@ -63,8 +63,6 @@ class SharedMemoryBasic final #endif } - virtual SharedMemoryType Type() const override { return TYPE_BASIC; } - static Handle NULLHandle() { return base::SharedMemory::NULLHandle(); } virtual bool IsHandleValid(const Handle& aHandle) const override { diff --git a/ipc/glue/SharedMemoryBasic_mach.h b/ipc/glue/SharedMemoryBasic_mach.h index 739177e6494f..e487c99c8468 100644 --- a/ipc/glue/SharedMemoryBasic_mach.h +++ b/ipc/glue/SharedMemoryBasic_mach.h @@ -51,8 +51,6 @@ class SharedMemoryBasic final #endif } - virtual SharedMemoryType Type() const override { return TYPE_BASIC; } - static Handle NULLHandle() { return Handle(); } static void* FindFreeAddressSpace(size_t aSize); diff --git a/ipc/glue/Shmem.cpp b/ipc/glue/Shmem.cpp index 642ddbbcf034..7a27c0c724b5 100644 --- a/ipc/glue/Shmem.cpp +++ b/ipc/glue/Shmem.cpp @@ -20,8 +20,7 @@ class ShmemCreated : public IPC::Message { typedef Shmem::id_t id_t; public: - ShmemCreated(int32_t routingId, id_t aIPDLId, size_t aSize, - SharedMemory::SharedMemoryType aType) + ShmemCreated(int32_t routingId, id_t aIPDLId, size_t aSize) : IPC::Message(routingId, SHMEM_CREATED_MESSAGE_TYPE, 0, HeaderFlags(NESTED_INSIDE_CPOW)) { MOZ_RELEASE_ASSERT(aSize < std::numeric_limits::max(), @@ -29,14 +28,12 @@ class ShmemCreated : public IPC::Message { IPC::MessageWriter writer(*this); IPC::WriteParam(&writer, aIPDLId); IPC::WriteParam(&writer, uint32_t(aSize)); - IPC::WriteParam(&writer, int32_t(aType)); } static bool ReadInfo(IPC::MessageReader* aReader, id_t* aIPDLId, - size_t* aSize, SharedMemory::SharedMemoryType* aType) { + size_t* aSize) { uint32_t size = 0; - if (!IPC::ReadParam(aReader, aIPDLId) || !IPC::ReadParam(aReader, &size) || - !IPC::ReadParam(aReader, reinterpret_cast(aType))) { + if (!IPC::ReadParam(aReader, aIPDLId) || !IPC::ReadParam(aReader, &size)) { return false; } *aSize = size; @@ -60,18 +57,11 @@ class ShmemDestroyed : public IPC::Message { } }; -static SharedMemory* NewSegment(SharedMemory::SharedMemoryType aType) { - if (SharedMemory::TYPE_BASIC == aType) { - return new SharedMemoryBasic; - } else { - NS_ERROR("unknown Shmem type"); - return nullptr; - } -} +static SharedMemory* NewSegment() { return new SharedMemoryBasic; } -static already_AddRefed CreateSegment( - SharedMemory::SharedMemoryType aType, size_t aNBytes, size_t aExtraSize) { - RefPtr segment = NewSegment(aType); +static already_AddRefed CreateSegment(size_t aNBytes, + size_t aExtraSize) { + RefPtr segment = NewSegment(); if (!segment) { return nullptr; } @@ -89,12 +79,11 @@ static already_AddRefed ReadSegment( NS_ERROR("expected 'shmem created' message"); return nullptr; } - SharedMemory::SharedMemoryType type; IPC::MessageReader reader(aDescriptor); - if (!ShmemCreated::ReadInfo(&reader, aId, aNBytes, &type)) { + if (!ShmemCreated::ReadInfo(&reader, aId, aNBytes)) { return nullptr; } - RefPtr segment = NewSegment(type); + RefPtr segment = NewSegment(); if (!segment) { return nullptr; } @@ -288,16 +277,14 @@ void Shmem::RevokeRights(PrivateIPDLCaller) { // static already_AddRefed Shmem::Alloc(PrivateIPDLCaller, - size_t aNBytes, - SharedMemoryType aType, - bool aUnsafe, + size_t aNBytes, bool aUnsafe, bool aProtect) { NS_ASSERTION(aNBytes <= UINT32_MAX, "Will truncate shmem segment size!"); MOZ_ASSERT(!aProtect || !aUnsafe, "protect => !unsafe"); size_t pageSize = SharedMemory::SystemPageSize(); // |2*pageSize| is for the front and back sentinel - RefPtr segment = CreateSegment(aType, aNBytes, 2 * pageSize); + RefPtr segment = CreateSegment(aNBytes, 2 * pageSize); if (!segment) { return nullptr; } @@ -388,11 +375,9 @@ Shmem::Shmem(PrivateIPDLCaller, SharedMemory* aSegment, id_t aId) // static already_AddRefed Shmem::Alloc(PrivateIPDLCaller, size_t aNBytes, - SharedMemoryType aType, bool /*unused*/, bool /*unused*/) { - RefPtr segment = - CreateSegment(aType, aNBytes, sizeof(uint32_t)); + RefPtr segment = CreateSegment(aNBytes, sizeof(uint32_t)); if (!segment) { return nullptr; } @@ -432,7 +417,7 @@ UniquePtr Shmem::MkCreatedMessage(PrivateIPDLCaller, int32_t routingId) { AssertInvariants(); - auto msg = MakeUnique(routingId, mId, mSize, mSegment->Type()); + auto msg = MakeUnique(routingId, mId, mSize); IPC::MessageWriter writer(*msg); if (!mSegment->WriteHandle(&writer)) { return nullptr; diff --git a/ipc/glue/Shmem.h b/ipc/glue/Shmem.h index 5ea73c719556..341c53e84218 100644 --- a/ipc/glue/Shmem.h +++ b/ipc/glue/Shmem.h @@ -74,7 +74,6 @@ class Shmem final { typedef int32_t id_t; // Low-level wrapper around platform shmem primitives. typedef mozilla::ipc::SharedMemory SharedMemory; - typedef SharedMemory::SharedMemoryType SharedMemoryType; // Shmem objects should only be constructed directly from SharedMemory // objects by the Shmem implementation itself, or by a select few functions // in ProtocolUtils.{h,cpp}. You should not need to add new instances of @@ -151,7 +150,6 @@ class Shmem final { static already_AddRefed Alloc(PrivateIPDLCaller, size_t aNBytes, - SharedMemoryType aType, bool aUnsafe, bool aProtect = false); diff --git a/ipc/ipdl/test/cxx/TestShmem.cpp b/ipc/ipdl/test/cxx/TestShmem.cpp index dcf7ae2f2196..0a778e53227e 100644 --- a/ipc/ipdl/test/cxx/TestShmem.cpp +++ b/ipc/ipdl/test/cxx/TestShmem.cpp @@ -13,10 +13,8 @@ void TestShmemParent::Main() { Shmem unsafe; size_t size = 12345; - if (!AllocShmem(size, SharedMemory::TYPE_BASIC, &mem)) - fail("can't alloc shmem"); - if (!AllocUnsafeShmem(size, SharedMemory::TYPE_BASIC, &unsafe)) - fail("can't alloc shmem"); + if (!AllocShmem(size, &mem)) fail("can't alloc shmem"); + if (!AllocUnsafeShmem(size, &unsafe)) fail("can't alloc shmem"); if (mem.Size() != size) fail("shmem is wrong size: expected %lu, got %lu", size, mem.Size()); diff --git a/tools/fuzzing/ipc/ProtocolFuzzer.h b/tools/fuzzing/ipc/ProtocolFuzzer.h index ad084f8aa5a6..f6782a8f2d90 100644 --- a/tools/fuzzing/ipc/ProtocolFuzzer.h +++ b/tools/fuzzing/ipc/ProtocolFuzzer.h @@ -73,8 +73,7 @@ void FuzzProtocol(T* aProtocol, const uint8_t* aData, size_t aSize, break; } RefPtr segment( - Shmem::Alloc(Shmem::PrivateIPDLCaller(), shmem_size, - SharedMemory::TYPE_BASIC, false)); + Shmem::Alloc(Shmem::PrivateIPDLCaller(), shmem_size, false)); if (!segment) { break; } diff --git a/tools/profiler/gecko/ProfilerChild.cpp b/tools/profiler/gecko/ProfilerChild.cpp index 18f9352dae2f..ba11ba8de00e 100644 --- a/tools/profiler/gecko/ProfilerChild.cpp +++ b/tools/profiler/gecko/ProfilerChild.cpp @@ -376,9 +376,7 @@ void ProfilerChild::GatherProfileThreadFunction( writer->ChunkedWriteFunc().CopyDataIntoLazilyAllocatedBuffer( [&](size_t allocationSize) -> char* { if (parameters->profilerChild->AllocShmem( - allocationSize, - mozilla::ipc::Shmem::SharedMemory::TYPE_BASIC, - &shmem)) { + allocationSize, &shmem)) { return shmem.get(); } return nullptr; @@ -386,9 +384,7 @@ void ProfilerChild::GatherProfileThreadFunction( writer = nullptr; } else { // No profile, send an empty string. - if (parameters->profilerChild->AllocShmem( - 1, mozilla::ipc::Shmem::SharedMemory::TYPE_BASIC, - &shmem)) { + if (parameters->profilerChild->AllocShmem(1, &shmem)) { shmem.get()[0] = '\0'; } } @@ -421,7 +417,7 @@ mozilla::ipc::IPCResult ProfilerChild::RecvGatherProfile( if (!gatherProfileThread) { // Failed to create and start worker thread, resolve with an empty profile. mozilla::ipc::Shmem shmem; - if (AllocShmem(1, mozilla::ipc::Shmem::SharedMemory::TYPE_BASIC, &shmem)) { + if (AllocShmem(1, &shmem)) { shmem.get()[0] = '\0'; } parameters->resolver(std::move(shmem));