Bumping manifests a=b2g-bump
[gecko.git] / dom / fetch / Request.h
bloba948d480969fcb79d35093e915bc3dbe4dd15d79
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_Request_h
7 #define mozilla_dom_Request_h
9 #include "nsISupportsImpl.h"
10 #include "nsWrapperCache.h"
12 #include "mozilla/dom/Fetch.h"
13 #include "mozilla/dom/InternalRequest.h"
14 // Required here due to certain WebIDL enums/classes being declared in both
15 // files.
16 #include "mozilla/dom/RequestBinding.h"
18 class nsPIDOMWindow;
20 namespace mozilla {
21 namespace dom {
23 class Headers;
24 class InternalHeaders;
25 class Promise;
26 class RequestOrUSVString;
28 class Request MOZ_FINAL : public nsISupports
29 , public nsWrapperCache
30 , public FetchBody<Request>
32 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
33 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Request)
35 public:
36 Request(nsIGlobalObject* aOwner, InternalRequest* aRequest);
38 JSObject*
39 WrapObject(JSContext* aCx) MOZ_OVERRIDE
41 return RequestBinding::Wrap(aCx, this);
44 void
45 GetUrl(DOMString& aUrl) const
47 aUrl.AsAString() = NS_ConvertUTF8toUTF16(mRequest->mURL);
50 void
51 GetMethod(nsCString& aMethod) const
53 aMethod = mRequest->mMethod;
56 RequestMode
57 Mode() const
59 return mRequest->mMode;
62 RequestCredentials
63 Credentials() const
65 return mRequest->mCredentialsMode;
68 void
69 GetReferrer(DOMString& aReferrer) const
71 if (mRequest->ReferrerIsNone()) {
72 aReferrer.AsAString() = EmptyString();
73 return;
76 // FIXME(nsm): Spec doesn't say what to do if referrer is client.
77 aReferrer.AsAString() = NS_ConvertUTF8toUTF16(mRequest->mReferrerURL);
80 InternalHeaders*
81 GetInternalHeaders() const
83 return mRequest->Headers();
86 Headers* Headers_();
88 void
89 GetBody(nsIInputStream** aStream) { return mRequest->GetBody(aStream); }
91 static already_AddRefed<Request>
92 Constructor(const GlobalObject& aGlobal, const RequestOrUSVString& aInput,
93 const RequestInit& aInit, ErrorResult& rv);
95 nsIGlobalObject* GetParentObject() const
97 return mOwner;
100 already_AddRefed<Request>
101 Clone() const;
103 already_AddRefed<InternalRequest>
104 GetInternalRequest();
105 private:
106 ~Request();
108 nsCOMPtr<nsIGlobalObject> mOwner;
109 nsRefPtr<InternalRequest> mRequest;
110 // Lazily created.
111 nsRefPtr<Headers> mHeaders;
114 } // namespace dom
115 } // namespace mozilla
117 #endif // mozilla_dom_Request_h