Bug 605362, part 4: Notify shmem MemoryReporters from all shmem backends. r=joe

This commit is contained in:
Chris Jones 2010-11-05 02:17:07 -05:00
parent d842dc7390
commit bb45a6061a
3 changed files with 29 additions and 6 deletions

View File

@ -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);
}
}
}

View File

@ -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;
}

View File

@ -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;
}