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 {
11 namespace dom {
12
CreateSlice(uint64_t aStart,uint64_t aLength,const nsAString & aContentType,ErrorResult & aRv)13 already_AddRefed<BlobImpl> EmptyBlobImpl::CreateSlice(
14 uint64_t aStart, uint64_t aLength, const nsAString& aContentType,
15 ErrorResult& aRv) {
16 MOZ_ASSERT(!aStart && !aLength);
17 RefPtr<BlobImpl> impl = new EmptyBlobImpl(aContentType);
18 return impl.forget();
19 }
20
CreateInputStream(nsIInputStream ** aStream,ErrorResult & aRv)21 void EmptyBlobImpl::CreateInputStream(nsIInputStream** aStream,
22 ErrorResult& aRv) {
23 if (NS_WARN_IF(!aStream)) {
24 aRv.Throw(NS_ERROR_FAILURE);
25 return;
26 }
27
28 nsresult rv = NS_NewCStringInputStream(aStream, EmptyCString());
29 if (NS_WARN_IF(NS_FAILED(rv))) {
30 aRv.Throw(rv);
31 return;
32 }
33 }
34
35 } // namespace dom
36 } // namespace mozilla
37