зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
da4fea8db5
Коммит
b8ebc73ff9
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче