Bug 1634779 - pt 2. Partially revert Bug 1603006 r=kmag
[gecko.git] / dom / fetch / BodyExtractor.h
blob33be3d6a211ae08e3e16be17265bd7a1339decf1
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/. */
7 #ifndef mozilla_dom_BodyExtractor_h
8 #define mozilla_dom_BodyExtractor_h
10 #include "jsapi.h"
11 #include "nsString.h"
13 class nsIInputStream;
14 class nsIGlobalObject;
16 namespace mozilla {
17 namespace dom {
19 class BodyExtractorBase {
20 public:
21 virtual nsresult GetAsStream(nsIInputStream** aResult,
22 uint64_t* aContentLength,
23 nsACString& aContentTypeWithCharset,
24 nsACString& aCharset) const = 0;
27 // The implementation versions of this template are:
28 // ArrayBuffer, ArrayBufferView, Blob, FormData,
29 // URLSearchParams, nsAString, Document, nsIInputStream.
30 template <typename Type>
31 class BodyExtractor final : public BodyExtractorBase {
32 Type* mBody;
34 public:
35 explicit BodyExtractor(Type* aBody) : mBody(aBody) {}
37 nsresult GetAsStream(nsIInputStream** aResult, uint64_t* aContentLength,
38 nsACString& aContentTypeWithCharset,
39 nsACString& aCharset) const override;
42 } // namespace dom
43 } // namespace mozilla
45 #endif // mozilla_dom_BodyExtractor_h