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 : #ifndef mozilla_dom_BodyExtractor_h
8 : #define mozilla_dom_BodyExtractor_h
9 :
10 : #include "nsString.h"
11 :
12 : class nsIInputStream;
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 2 : class BodyExtractorBase
18 : {
19 : public:
20 : virtual nsresult GetAsStream(nsIInputStream** aResult,
21 : uint64_t* aContentLength,
22 : nsACString& aContentTypeWithCharset,
23 : nsACString& aCharset) const = 0;
24 : };
25 :
26 : // The implementation versions of this template are:
27 : // ArrayBuffer, ArrayBufferView, nsIXHRSendable (Blob, FormData,
28 : // URLSearchParams), nsAString, nsIDocument, nsIInputStream
29 : template<typename Type>
30 : class BodyExtractor final : public BodyExtractorBase
31 : {
32 : Type* mBody;
33 : public:
34 2 : explicit BodyExtractor(Type* aBody) : mBody(aBody)
35 2 : {}
36 :
37 : nsresult GetAsStream(nsIInputStream** aResult,
38 : uint64_t* aContentLength,
39 : nsACString& aContentTypeWithCharset,
40 : nsACString& aCharset) const override;
41 : };
42 :
43 : } // dom namespace
44 : } // mozilla namespace
45 :
46 : #endif // mozilla_dom_BodyExtractor_h
|