diff --git a/dom/file/Blob.cpp b/dom/file/Blob.cpp index fbba4b769997..6bf5b79ca14e 100644 --- a/dom/file/Blob.cpp +++ b/dom/file/Blob.cpp @@ -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::CreateEmptyBlob(nsISupports* aParent, + const nsAString& aContentType) { + RefPtr blob = Blob::Create(aParent, new EmptyBlobImpl(aContentType)); + MOZ_ASSERT(!blob->mImpl->IsFile()); + return blob.forget(); +} + /* static */ already_AddRefed Blob::CreateStringBlob(nsISupports* aParent, const nsACString& aData, diff --git a/dom/file/Blob.h b/dom/file/Blob.h index bc3e718bd184..cd7846a315f8 100644 --- a/dom/file/Blob.h +++ b/dom/file/Blob.h @@ -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 CreateEmptyBlob(nsISupports* aParent, + const nsAString& aContentType); + static already_AddRefed CreateStringBlob(nsISupports* aParent, const nsACString& aData, const nsAString& aContentType);