Bug 1600595: Part 1 - Consolidate ShmemAllocator and IShmemAllocator into one class r=nical

IShmemAllocator was introduced in bug 1272018 as a planned replacement for ShmemAllocator.  They are essentially the same interface.  This patch removes ShmemAllocator.

Differential Revision: https://phabricator.services.mozilla.com/D56224

--HG--
extra : moz-landing-system : lando
This commit is contained in:
David Parks 2020-01-04 19:34:59 +00:00
Родитель b3d907498a
Коммит 611dfe0fcb
9 изменённых файлов: 28 добавлений и 44 удалений

Просмотреть файл

@ -170,8 +170,8 @@ bool CompositorBridgeParentBase::AllocUnsafeShmem(
return PCompositorBridgeParent::AllocUnsafeShmem(aSize, aType, aShmem);
}
void CompositorBridgeParentBase::DeallocShmem(ipc::Shmem& aShmem) {
PCompositorBridgeParent::DeallocShmem(aShmem);
bool CompositorBridgeParentBase::DeallocShmem(ipc::Shmem& aShmem) {
return PCompositorBridgeParent::DeallocShmem(aShmem);
}
static inline MessageLoop* CompositorLoop() {

Просмотреть файл

@ -32,7 +32,7 @@
#include "mozilla/layers/CompositorOptions.h"
#include "mozilla/layers/CompositorVsyncSchedulerOwner.h"
#include "mozilla/layers/GeckoContentController.h"
#include "mozilla/layers/ISurfaceAllocator.h" // for ShmemAllocator
#include "mozilla/layers/ISurfaceAllocator.h" // for IShmemAllocator
#include "mozilla/layers/LayersMessages.h" // for TargetConfig
#include "mozilla/layers/MetricsSharingController.h"
#include "mozilla/layers/PCompositorBridgeTypes.h"
@ -106,7 +106,7 @@ struct ScopedLayerTreeRegistration {
class CompositorBridgeParentBase : public PCompositorBridgeParent,
public HostIPCAllocator,
public ShmemAllocator,
public mozilla::ipc::IShmemAllocator,
public MetricsSharingController {
friend class PCompositorBridgeParent;
@ -149,7 +149,7 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent,
virtual void RegisterPayloads(LayerTransactionParent* aLayerTree,
const nsTArray<CompositionPayload>& aPayload) {}
ShmemAllocator* AsShmemAllocator() override { return this; }
IShmemAllocator* AsShmemAllocator() override { return this; }
CompositorBridgeParentBase* AsCompositorBridgeParentBase() override {
return this;
@ -170,14 +170,14 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent,
void SendAsyncMessage(
const nsTArray<AsyncParentMessageData>& aMessage) override;
// ShmemAllocator
// 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;
void DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
// MetricsSharingController
NS_IMETHOD_(MozExternalRefCountType) AddRef() override {

Просмотреть файл

@ -33,7 +33,6 @@ class CompositableForwarder;
class CompositorBridgeParentBase;
class TextureForwarder;
class ShmemAllocator;
class ShmemSectionAllocator;
class LegacySurfaceDescriptorAllocator;
class ClientIPCAllocator;
@ -74,7 +73,7 @@ class ISurfaceAllocator {
// down-casting
virtual ShmemAllocator* AsShmemAllocator() { return nullptr; }
virtual mozilla::ipc::IShmemAllocator* AsShmemAllocator() { return nullptr; }
virtual ShmemSectionAllocator* AsShmemSectionAllocator() { return nullptr; }
@ -156,21 +155,6 @@ class HostIPCAllocator : public ISurfaceAllocator {
bool mAboutToSendAsyncMessages = false;
};
/// An allocator can provide shared memory.
///
/// The allocated shmems can be deallocated on either process, as long as they
/// belong to the same channel.
class ShmemAllocator {
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 void DeallocShmem(mozilla::ipc::Shmem& aShmem) = 0;
};
/// An allocator that can group allocations in bigger chunks of shared memory.
///
/// The allocated shmem sections can only be deallocated by the same allocator

Просмотреть файл

@ -403,11 +403,11 @@ bool ImageBridgeParent::AllocUnsafeShmem(
return PImageBridgeParent::AllocUnsafeShmem(aSize, aType, aShmem);
}
void ImageBridgeParent::DeallocShmem(ipc::Shmem& aShmem) {
bool ImageBridgeParent::DeallocShmem(ipc::Shmem& aShmem) {
if (mClosed) {
return;
return false;
}
PImageBridgeParent::DeallocShmem(aShmem);
return PImageBridgeParent::DeallocShmem(aShmem);
}
bool ImageBridgeParent::IsSameProcess() const {

Просмотреть файл

@ -39,7 +39,7 @@ struct ImageCompositeNotificationInfo;
*/
class ImageBridgeParent final : public PImageBridgeParent,
public CompositableParentManager,
public ShmemAllocator {
public mozilla::ipc::IShmemAllocator {
public:
typedef nsTArray<CompositableOperation> EditArray;
typedef nsTArray<OpDestroy> OpDestroyArray;
@ -60,7 +60,7 @@ class ImageBridgeParent final : public PImageBridgeParent,
static bool CreateForContent(Endpoint<PImageBridgeParent>&& aEndpoint);
static void Shutdown();
ShmemAllocator* AsShmemAllocator() override { return this; }
IShmemAllocator* AsShmemAllocator() override { return this; }
void ActorDestroy(ActorDestroyReason aWhy) override;
@ -100,7 +100,7 @@ class ImageBridgeParent final : public PImageBridgeParent,
MessageLoop* GetMessageLoop() const { return mMessageLoop; }
// ShmemAllocator
// IShmemAllocator
bool AllocShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem) override;
@ -108,7 +108,7 @@ class ImageBridgeParent final : public PImageBridgeParent,
bool AllocUnsafeShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem) override;
void DeallocShmem(ipc::Shmem& aShmem) override;
bool DeallocShmem(ipc::Shmem& aShmem) override;
bool IsSameProcess() const override;

Просмотреть файл

@ -885,11 +885,11 @@ bool LayerTransactionParent::AllocUnsafeShmem(
return PLayerTransactionParent::AllocUnsafeShmem(aSize, aType, aShmem);
}
void LayerTransactionParent::DeallocShmem(ipc::Shmem& aShmem) {
bool LayerTransactionParent::DeallocShmem(ipc::Shmem& aShmem) {
if (!mIPCOpen || mDestroyed) {
return;
return false;
}
PLayerTransactionParent::DeallocShmem(aShmem);
return PLayerTransactionParent::DeallocShmem(aShmem);
}
bool LayerTransactionParent::IsSameProcess() const {

Просмотреть файл

@ -33,7 +33,7 @@ class CompositorBridgeParentBase;
class LayerTransactionParent final : public PLayerTransactionParent,
public CompositableParentManager,
public ShmemAllocator {
public mozilla::ipc::IShmemAllocator {
typedef nsTArray<Edit> EditArray;
typedef nsTArray<OpDestroy> OpDestroyArray;
typedef nsTArray<PluginWindowData> PluginsArray;
@ -61,7 +61,7 @@ class LayerTransactionParent final : public PLayerTransactionParent,
LayersObserverEpoch GetChildEpoch() const { return mChildEpoch; }
bool ShouldParentObserveEpoch();
ShmemAllocator* AsShmemAllocator() override { return this; }
IShmemAllocator* AsShmemAllocator() override { return this; }
bool AllocShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem) override;
@ -69,7 +69,7 @@ class LayerTransactionParent final : public PLayerTransactionParent,
bool AllocUnsafeShmem(size_t aSize, ipc::SharedMemory::SharedMemoryType aType,
ipc::Shmem* aShmem) override;
void DeallocShmem(ipc::Shmem& aShmem) override;
bool DeallocShmem(ipc::Shmem& aShmem) override;
bool IsSameProcess() const override;

Просмотреть файл

@ -134,11 +134,11 @@ bool VideoBridgeParent::AllocUnsafeShmem(
return PVideoBridgeParent::AllocUnsafeShmem(aSize, aType, aShmem);
}
void VideoBridgeParent::DeallocShmem(ipc::Shmem& aShmem) {
bool VideoBridgeParent::DeallocShmem(ipc::Shmem& aShmem) {
if (mClosed) {
return;
return false;
}
PVideoBridgeParent::DeallocShmem(aShmem);
return PVideoBridgeParent::DeallocShmem(aShmem);
}
bool VideoBridgeParent::IsSameProcess() const {

Просмотреть файл

@ -18,7 +18,7 @@ class CompositorThreadHolder;
class VideoBridgeParent final : public PVideoBridgeParent,
public HostIPCAllocator,
public ShmemAllocator {
public mozilla::ipc::IShmemAllocator {
public:
~VideoBridgeParent();
@ -46,18 +46,18 @@ class VideoBridgeParent final : public PVideoBridgeParent,
const nsTArray<AsyncParentMessageData>& aMessage) override;
// ISurfaceAllocator
ShmemAllocator* AsShmemAllocator() override { return this; }
IShmemAllocator* AsShmemAllocator() override { return this; }
bool IsSameProcess() const override;
bool IPCOpen() const override { return !mClosed; }
// ShmemAllocator
// IShmemAllocator
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;
bool DeallocShmem(ipc::Shmem& aShmem) override;
private:
explicit VideoBridgeParent(VideoBridgeSource aSource);