diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 9fb8e0cddbe0..6dd5b60389bc 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -4977,7 +4977,7 @@ mozilla::ipc::IPCResult ContentParent::RecvGetOutputColorProfileData( mozilla::ipc::IPCResult ContentParent::RecvGetFontListShmBlock( const uint32_t& aGeneration, const uint32_t& aIndex, - mozilla::ipc::SharedMemoryBasic::Handle* aOut) { + base::SharedMemoryHandle* aOut) { auto fontList = gfxPlatformFontList::PlatformFontList(); MOZ_RELEASE_ASSERT(fontList, "gfxPlatformFontList not initialized?"); fontList->ShareFontListShmBlockToProcess(aGeneration, aIndex, Pid(), aOut); diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 94304b6bc9a3..f9ae5005bd1b 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -1148,7 +1148,7 @@ class ContentParent final mozilla::ipc::IPCResult RecvGetFontListShmBlock( const uint32_t& aGeneration, const uint32_t& aIndex, - mozilla::ipc::SharedMemoryBasic::Handle* aOut); + base::SharedMemoryHandle* aOut); mozilla::ipc::IPCResult RecvInitializeFamily(const uint32_t& aGeneration, const uint32_t& aFamilyIndex); diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index ee51ffb2aa71..e0125b6346d9 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -1266,7 +1266,7 @@ parent: * until it has mapped the font-list memory. */ sync GetFontListShmBlock(uint32_t aGeneration, uint32_t aIndex) - returns (Handle aHandle); + returns (SharedMemoryHandle aHandle); /** * Ask the parent to initialize a given font family, so that face metadata diff --git a/gfx/thebes/SharedFontList-impl.h b/gfx/thebes/SharedFontList-impl.h index 31e537f9a737..55d09e3961c3 100644 --- a/gfx/thebes/SharedFontList-impl.h +++ b/gfx/thebes/SharedFontList-impl.h @@ -7,7 +7,7 @@ #include "SharedFontList.h" -#include "mozilla/ipc/SharedMemoryBasic.h" +#include "base/shared_memory.h" #include "gfxFontUtils.h" #include "nsClassHashtable.h" @@ -224,10 +224,10 @@ class FontList { * specific child process. */ void ShareShmBlockToProcess(uint32_t aIndex, base::ProcessId aPid, - mozilla::ipc::SharedMemoryBasic::Handle* aOut) { + base::SharedMemoryHandle* aOut) { if (aIndex >= mBlocks.Length()) { // Block index out of range - *aOut = mozilla::ipc::SharedMemoryBasic::NULLHandle(); + *aOut = base::SharedMemory::NULLHandle(); } if (!mBlocks[aIndex]->mShmem->ShareToProcess(aPid, aOut)) { MOZ_CRASH("failed to share block"); @@ -240,7 +240,7 @@ class FontList { size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t result = mBlocks.ShallowSizeOfExcludingThis(aMallocSizeOf); for (const auto& b : mBlocks) { - result += aMallocSizeOf(b.get()) + aMallocSizeOf(b->mShmem); + result += aMallocSizeOf(b.get()) + aMallocSizeOf(b->mShmem.get()); } return result; } @@ -268,7 +268,8 @@ class FontList { private: struct ShmBlock { - ShmBlock(mozilla::ipc::SharedMemoryBasic* aShmem, void* aAddr) + // Takes ownership of aShmem + ShmBlock(base::SharedMemory* aShmem, void* aAddr) : mShmem(aShmem), mAddr(aAddr) {} // The first 32-bit word of each block holds the current amount allocated @@ -278,7 +279,7 @@ class FontList { return *static_cast*>(mAddr); } - RefPtr mShmem; + mozilla::UniquePtr mShmem; void* mAddr; // Address where the shared memory block is mapped in this // process; avoids virtual call to mShmem->memory() each time // we need to convert between Pointer and a real C++ pointer. diff --git a/gfx/thebes/SharedFontList.cpp b/gfx/thebes/SharedFontList.cpp index ac830d72dc67..343991a2a62a 100644 --- a/gfx/thebes/SharedFontList.cpp +++ b/gfx/thebes/SharedFontList.cpp @@ -519,7 +519,7 @@ FontList::~FontList() { DetachShmBlocks(); } bool FontList::AppendShmBlock() { MOZ_ASSERT(XRE_IsParentProcess()); - ipc::SharedMemoryBasic* newShm = new ipc::SharedMemoryBasic(); + base::SharedMemory* newShm = new base::SharedMemory(); if (!newShm->Create(SHM_BLOCK_SIZE)) { MOZ_CRASH("failed to create shared memory"); return false; @@ -556,17 +556,16 @@ FontList::ShmBlock* FontList::GetBlockFromParent(uint32_t aIndex) { // If we have no existing blocks, we don't want a generation check yet; // the header in the first block will define the generation of this list uint32_t generation = aIndex == 0 ? 0 : GetGeneration(); - ipc::SharedMemoryBasic::Handle handle = ipc::SharedMemoryBasic::NULLHandle(); + base::SharedMemoryHandle handle = base::SharedMemory::NULLHandle(); if (!dom::ContentChild::GetSingleton()->SendGetFontListShmBlock( generation, aIndex, &handle)) { return nullptr; } - RefPtr newShm = new ipc::SharedMemoryBasic(); + base::SharedMemory* newShm = new base::SharedMemory(); if (!newShm->IsHandleValid(handle)) { return nullptr; } - if (!newShm->SetHandle(handle, - mozilla::ipc::SharedMemoryBasic::RightsReadOnly)) { + if (!newShm->SetHandle(handle, true)) { MOZ_CRASH("failed to set shm handle"); } if (!newShm->Map(SHM_BLOCK_SIZE)) { diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index 2654a5774516..330efaf2cffe 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -2267,17 +2267,16 @@ void gfxPlatformFontList::CancelInitOtherFamilyNamesTask() { } void gfxPlatformFontList::ShareFontListShmBlockToProcess( - uint32_t aGeneration, uint32_t aIndex, /*base::ProcessId*/ uint32_t aPid, - /*mozilla::ipc::SharedMemoryBasic::Handle*/ void* aOut) { + uint32_t aGeneration, uint32_t aIndex, base::ProcessId aPid, + base::SharedMemoryHandle* aOut) { auto list = SharedFontList(); if (!list) { return; } - auto out = static_cast(aOut); if (!aGeneration || list->GetGeneration() == aGeneration) { - list->ShareShmBlockToProcess(aIndex, aPid, out); + list->ShareShmBlockToProcess(aIndex, aPid, aOut); } else { - *out = mozilla::ipc::SharedMemoryBasic::NULLHandle(); + *aOut = base::SharedMemory::NULLHandle(); } } diff --git a/gfx/thebes/gfxPlatformFontList.h b/gfx/thebes/gfxPlatformFontList.h index 505f115028df..8b364ddaa488 100644 --- a/gfx/thebes/gfxPlatformFontList.h +++ b/gfx/thebes/gfxPlatformFontList.h @@ -27,6 +27,8 @@ #include "mozilla/RangedArray.h" #include "nsLanguageAtomService.h" +#include "base/shared_memory.h" + namespace mozilla { namespace fontlist { struct AliasData; @@ -262,8 +264,8 @@ class gfxPlatformFontList : public gfxFontInfoLoader { // result in build failure due to (indirect) inclusion of windows.h // in generated bindings code. void ShareFontListShmBlockToProcess( - uint32_t aGeneration, uint32_t aIndex, /*base::ProcessId*/ uint32_t aPid, - /*mozilla::ipc::SharedMemoryBasic::Handle*/ void* aOut); + uint32_t aGeneration, uint32_t aIndex, base::ProcessId aPid, + base::SharedMemoryHandle* aOut); void SetCharacterMap(uint32_t aGeneration, const mozilla::fontlist::Pointer& aFacePtr,