mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 10:08:41 +00:00
Bug 605362, part 4: Notify shmem MemoryReporters from all shmem backends. r=joe
This commit is contained in:
parent
d842dc7390
commit
bb45a6061a
@ -108,6 +108,7 @@ SharedMemoryBasic::Create(size_t aNbytes)
|
||||
|
||||
mShmFd = shmfd;
|
||||
mAllocSize = aNbytes;
|
||||
Created(aNbytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -128,6 +129,7 @@ SharedMemoryBasic::Map(size_t nBytes)
|
||||
}
|
||||
|
||||
mSize = nBytes;
|
||||
Mapped(nBytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -160,6 +162,7 @@ SharedMemoryBasic::Unmap()
|
||||
}
|
||||
mMemory = nsnull;
|
||||
mSize = 0;
|
||||
Unmapped(mSize);
|
||||
}
|
||||
|
||||
void
|
||||
@ -167,6 +170,9 @@ SharedMemoryBasic::Destroy()
|
||||
{
|
||||
if (mShmFd > 0) {
|
||||
close(mShmFd);
|
||||
if (mAllocSize) {
|
||||
Destroyed(mAllocSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,12 +71,22 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~SharedMemoryBasic() {
|
||||
if (memory()) {
|
||||
Unmapped(mSize);
|
||||
}
|
||||
if (mAllocSize) {
|
||||
Destroyed(mAllocSize);
|
||||
}
|
||||
}
|
||||
|
||||
NS_OVERRIDE
|
||||
virtual bool Create(size_t aNbytes)
|
||||
{
|
||||
bool ok = mSharedMemory.Create("", false, false, aNbytes);
|
||||
if (ok) {
|
||||
mAllocSize = aNbytes;
|
||||
Created(aNbytes);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
@ -85,8 +95,10 @@ public:
|
||||
virtual bool Map(size_t nBytes)
|
||||
{
|
||||
bool ok = mSharedMemory.Map(nBytes);
|
||||
if (ok)
|
||||
if (ok) {
|
||||
mSize = nBytes;
|
||||
Mapped(nBytes);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -90,11 +90,17 @@ public:
|
||||
|
||||
virtual ~SharedMemorySysV()
|
||||
{
|
||||
if (memory()) {
|
||||
Unmapped(mSize);
|
||||
}
|
||||
if (mAllocSize) {
|
||||
Destroyed(mAllocSize);
|
||||
}
|
||||
|
||||
shmdt(mData);
|
||||
mHandle = -1;
|
||||
mData = nsnull;
|
||||
mSize = 0;
|
||||
|
||||
}
|
||||
|
||||
NS_OVERRIDE
|
||||
@ -106,11 +112,9 @@ public:
|
||||
|
||||
mHandle = id;
|
||||
mAllocSize = aNbytes;
|
||||
Created(aNbytes);
|
||||
|
||||
if (!Map(aNbytes))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return Map(aNbytes);
|
||||
}
|
||||
|
||||
NS_OVERRIDE
|
||||
@ -150,6 +154,7 @@ public:
|
||||
"Segment doesn't have enough space!");
|
||||
#endif
|
||||
|
||||
Mapped(nBytes);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user