Line data Source code
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 :
13 0 : NS_IMPL_ISUPPORTS_INHERITED0(EmptyBlobImpl, BlobImpl)
14 :
15 : already_AddRefed<BlobImpl>
16 0 : EmptyBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength,
17 : const nsAString& aContentType,
18 : ErrorResult& aRv)
19 : {
20 0 : MOZ_ASSERT(!aStart && !aLength);
21 0 : RefPtr<BlobImpl> impl = new EmptyBlobImpl(aContentType);
22 :
23 0 : DebugOnly<bool> isMutable;
24 0 : MOZ_ASSERT(NS_SUCCEEDED(impl->GetMutable(&isMutable)));
25 0 : MOZ_ASSERT(!isMutable);
26 :
27 0 : return impl.forget();
28 : }
29 :
30 : void
31 0 : EmptyBlobImpl::GetInternalStream(nsIInputStream** aStream,
32 : ErrorResult& aRv)
33 : {
34 0 : if (NS_WARN_IF(!aStream)) {
35 0 : aRv.Throw(NS_ERROR_FAILURE);
36 0 : return;
37 : }
38 :
39 0 : nsresult rv = NS_NewCStringInputStream(aStream, EmptyCString());
40 0 : if (NS_WARN_IF(NS_FAILED(rv))) {
41 0 : aRv.Throw(rv);
42 0 : return;
43 : }
44 : }
45 :
46 : } // namespace dom
47 : } // namespace mozilla
|