Bug 1340921 - Introduce PMemoryStream for having PBlob and Multi-e10s happy - part 4 - Delete of the PMemoryStream actor, r=mrbkap

This commit is contained in:
Andrea Marchesini 2017-03-29 10:40:38 +02:00
Родитель 0132b2fc81
Коммит f6b3cb0b74
2 изменённых файлов: 60 добавлений и 1 удалений

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

@ -664,6 +664,63 @@ SerializeInputStreamInChunks(nsIInputStream* aInputStream, uint64_t aLength,
return child;
}
void
DeleteStreamMemoryFromBlobDataStream(BlobDataStream& aStream)
{
PMemoryStreamChild* actor = aStream.streamChild();
if (actor) {
actor->Send__delete__(actor);
}
}
void
DeleteStreamMemoryFromBlobData(BlobData& aBlobData)
{
switch (aBlobData.type()) {
case BlobData::TBlobDataStream:
DeleteStreamMemoryFromBlobDataStream(aBlobData.get_BlobDataStream());
return;
case BlobData::TArrayOfBlobData: {
nsTArray<BlobData>& arrayBlobData = aBlobData.get_ArrayOfBlobData();
for (uint32_t i = 0; i < arrayBlobData.Length(); ++i) {
DeleteStreamMemoryFromBlobData(arrayBlobData[i]);
}
return;
}
default:
// Nothing to do here.
return;
}
}
void
DeleteStreamMemoryFromOptionalBlobData(OptionalBlobData& aParams)
{
if (aParams.type() == OptionalBlobData::Tvoid_t) {
return;
}
DeleteStreamMemoryFromBlobData(aParams.get_BlobData());
}
void
DeleteStreamMemory(AnyBlobConstructorParams& aParams)
{
if (aParams.type() == AnyBlobConstructorParams::TFileBlobConstructorParams) {
FileBlobConstructorParams& fileParams = aParams.get_FileBlobConstructorParams();
DeleteStreamMemoryFromOptionalBlobData(fileParams.optionalBlobData());
return;
}
if (aParams.type() == AnyBlobConstructorParams::TNormalBlobConstructorParams) {
NormalBlobConstructorParams& normalParams = aParams.get_NormalBlobConstructorParams();
DeleteStreamMemoryFromOptionalBlobData(normalParams.optionalBlobData());
return;
}
}
} // namespace
already_AddRefed<BlobImpl>
@ -3580,6 +3637,8 @@ BlobChild::GetOrCreateFromImpl(ChildManagerType* aManager,
return nullptr;
}
DeleteStreamMemory(params.blobParams());
return actor;
}

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

@ -16,7 +16,7 @@ namespace dom {
class MemoryStreamParent final : public mozilla::ipc::PMemoryStreamParent
{
public:
MemoryStreamParent(uint64_t aSize);
explicit MemoryStreamParent(uint64_t aSize);
mozilla::ipc::IPCResult
RecvAddChunk(nsTArray<unsigned char>&& aData) override;