Bug 1014393 - Add Blob::CreateEmptyBlob. r=baku

I needed empty blobs in MediaRecorder and seeing that there was no
Blob::CreateEmptyBlob, nor an export of EmptyBlobImpl, I thought
Blob::CreateEmptyBlob would be the cleaner solution, so here it is.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2019-07-12 13:41:48 +00:00
Родитель 25e0a96f86
Коммит 8d5c8d17a4
2 изменённых файлов: 12 добавлений и 0 удалений

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

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Blob.h"
#include "EmptyBlobImpl.h"
#include "File.h"
#include "MemoryBlobImpl.h"
#include "mozilla/dom/BlobBinding.h"
@ -72,6 +73,14 @@ Blob* Blob::Create(nsISupports* aParent, BlobImpl* aImpl) {
return aImpl->IsFile() ? new File(aParent, aImpl) : new Blob(aParent, aImpl);
}
/* static */
already_AddRefed<Blob> Blob::CreateEmptyBlob(nsISupports* aParent,
const nsAString& aContentType) {
RefPtr<Blob> blob = Blob::Create(aParent, new EmptyBlobImpl(aContentType));
MOZ_ASSERT(!blob->mImpl->IsFile());
return blob.forget();
}
/* static */
already_AddRefed<Blob> Blob::CreateStringBlob(nsISupports* aParent,
const nsACString& aData,

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

@ -50,6 +50,9 @@ class Blob : public nsIMutable,
// This creates a Blob or a File based on the type of BlobImpl.
static Blob* Create(nsISupports* aParent, BlobImpl* aImpl);
static already_AddRefed<Blob> CreateEmptyBlob(nsISupports* aParent,
const nsAString& aContentType);
static already_AddRefed<Blob> CreateStringBlob(nsISupports* aParent,
const nsACString& aData,
const nsAString& aContentType);