Bug 1777535 - Simplify Buffer::Cleanup. r=jimb

Make sure to always clean up any potential content-side state and only avoid sending Destroy each time.

Depends on D151621

Differential Revision: https://phabricator.services.mozilla.com/D151629
This commit is contained in:
Nicolas Silva 2022-08-10 11:38:55 +00:00
Родитель c87019923a
Коммит 466aec98aa
1 изменённых файлов: 13 добавлений и 17 удалений

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

@ -108,26 +108,22 @@ bool Buffer::Mappable() const {
void Buffer::Cleanup() {
AbortMapRequest();
if (mValid && mParent) {
mValid = false;
if (mMapped && !mMapped->mArrayBuffers.IsEmpty()) {
// The array buffers could live longer than us and our shmem, so make sure
// we clear the external buffer bindings.
dom::AutoJSAPI jsapi;
if (jsapi.Init(mParent->GetOwnerGlobal())) {
IgnoredErrorResult rv;
UnmapArrayBuffers(jsapi.cx(), rv);
}
}
auto bridge = mParent->GetBridge();
if (bridge && bridge->IsOpen()) {
// Tell the parent side the about the imminent disparition of the shmem
// *before* deallocating it.
bridge->SendBufferDestroy(mId);
if (mMapped && !mMapped->mArrayBuffers.IsEmpty()) {
// The array buffers could live longer than us and our shmem, so make sure
// we clear the external buffer bindings.
dom::AutoJSAPI jsapi;
if (jsapi.Init(mParent->GetOwnerGlobal())) {
IgnoredErrorResult rv;
UnmapArrayBuffers(jsapi.cx(), rv);
}
}
mMapped.reset();
if (mValid && !mParent->IsLost()) {
mParent->GetBridge()->SendBufferDestroy(mId);
}
mValid = false;
}
void Buffer::SetMapped(BufferAddress aOffset, BufferAddress aSize,