1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #include "EmptyBlobImpl.h"
8 #include "nsStringStream.h"
9 
10 namespace mozilla::dom {
11 
CreateSlice(uint64_t aStart,uint64_t aLength,const nsAString & aContentType,ErrorResult & aRv)12 already_AddRefed<BlobImpl> EmptyBlobImpl::CreateSlice(
13     uint64_t aStart, uint64_t aLength, const nsAString& aContentType,
14     ErrorResult& aRv) {
15   MOZ_ASSERT(!aStart && !aLength);
16   RefPtr<BlobImpl> impl = new EmptyBlobImpl(aContentType);
17   return impl.forget();
18 }
19 
CreateInputStream(nsIInputStream ** aStream,ErrorResult & aRv)20 void EmptyBlobImpl::CreateInputStream(nsIInputStream** aStream,
21                                       ErrorResult& aRv) {
22   if (NS_WARN_IF(!aStream)) {
23     aRv.Throw(NS_ERROR_FAILURE);
24     return;
25   }
26 
27   nsresult rv = NS_NewCStringInputStream(aStream, ""_ns);
28   if (NS_WARN_IF(NS_FAILED(rv))) {
29     aRv.Throw(rv);
30     return;
31   }
32 }
33 
34 }  // namespace mozilla::dom
35