Bumping manifests a=b2g-bump
[gecko.git] / dom / fetch / Response.h
bloba23f8f4701826ea2c830f9e147a773b6cf87575e
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_Response_h
7 #define mozilla_dom_Response_h
9 #include "nsWrapperCache.h"
10 #include "nsISupportsImpl.h"
12 #include "mozilla/dom/Fetch.h"
13 #include "mozilla/dom/ResponseBinding.h"
15 #include "InternalResponse.h"
17 class nsPIDOMWindow;
19 namespace mozilla {
20 namespace dom {
22 class ArrayBufferOrArrayBufferViewOrUSVStringOrURLSearchParams;
23 class Headers;
24 class InternalHeaders;
25 class Promise;
27 class Response MOZ_FINAL : public nsISupports
28 , public nsWrapperCache
29 , public FetchBody<Response>
31 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Response)
34 public:
35 Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse);
37 Response(const Response& aOther) = delete;
39 JSObject*
40 WrapObject(JSContext* aCx) MOZ_OVERRIDE
42 return ResponseBinding::Wrap(aCx, this);
45 ResponseType
46 Type() const
48 return mInternalResponse->Type();
51 void
52 GetUrl(DOMString& aUrl) const
54 nsCString url;
55 mInternalResponse->GetUrl(url);
56 aUrl.AsAString() = NS_ConvertUTF8toUTF16(url);
59 uint16_t
60 Status() const
62 return mInternalResponse->GetStatus();
65 void
66 GetStatusText(nsCString& aStatusText) const
68 aStatusText = mInternalResponse->GetStatusText();
71 InternalHeaders*
72 GetInternalHeaders() const
74 return mInternalResponse->Headers();
77 Headers* Headers_();
79 void
80 GetBody(nsIInputStream** aStream) { return mInternalResponse->GetBody(aStream); }
82 static already_AddRefed<Response>
83 Error(const GlobalObject& aGlobal);
85 static already_AddRefed<Response>
86 Redirect(const GlobalObject& aGlobal, const nsAString& aUrl, uint16_t aStatus);
88 static already_AddRefed<Response>
89 Constructor(const GlobalObject& aGlobal,
90 const Optional<ArrayBufferOrArrayBufferViewOrBlobOrUSVStringOrURLSearchParams>& aBody,
91 const ResponseInit& aInit, ErrorResult& rv);
93 nsIGlobalObject* GetParentObject() const
95 return mOwner;
98 already_AddRefed<Response>
99 Clone();
101 void
102 SetBody(nsIInputStream* aBody);
103 private:
104 ~Response();
106 nsCOMPtr<nsIGlobalObject> mOwner;
107 nsRefPtr<InternalResponse> mInternalResponse;
108 // Lazily created
109 nsRefPtr<Headers> mHeaders;
112 } // namespace dom
113 } // namespace mozilla
115 #endif // mozilla_dom_Response_h