/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- *//* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */#ifndef mozilla_dom_Request_h#define mozilla_dom_Request_h#include"nsIContentPolicy.h"#include"nsISupportsImpl.h"#include"nsWrapperCache.h"#include"mozilla/dom/Fetch.h"#include"mozilla/dom/InternalRequest.h"// Required here due to certain WebIDL enums/classes being declared in both// files.#include"mozilla/dom/RequestBinding.h"classnsPIDOMWindow;namespacemozilla{namespacedom{classHeaders;classInternalHeaders;classPromise;classRequestOrUSVString;classRequestfinal:publicnsISupports,publicFetchBody<Request>,publicnsWrapperCache{NS_DECL_CYCLE_COLLECTING_ISUPPORTSNS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Request)public:Request(nsIGlobalObject*aOwner,InternalRequest*aRequest);JSObject*WrapObject(JSContext*aCx,JS::Handle<JSObject*>aGivenProto)override{returnRequestBinding::Wrap(aCx,this,aGivenProto);}voidGetUrl(nsAString&aUrl)const{CopyUTF8toUTF16(mRequest->mURL,aUrl);}voidGetMethod(nsCString&aMethod)const{aMethod=mRequest->mMethod;}RequestModeMode()const{if(mRequest->mMode==RequestMode::Cors_with_forced_preflight){returnRequestMode::Cors;}returnmRequest->mMode;}RequestCredentialsCredentials()const{returnmRequest->mCredentialsMode;}RequestCacheCache()const{returnmRequest->GetCacheMode();}RequestContextContext()const{returnmContext;}// [ChromeOnly]voidSetContext(RequestContextaContext){mContext=aContext;}voidGetReferrer(nsAString&aReferrer)const{mRequest->GetReferrer(aReferrer);}InternalHeaders*GetInternalHeaders()const{returnmRequest->Headers();}Headers*Headers_();voidGetBody(nsIInputStream**aStream){returnmRequest->GetBody(aStream);}staticalready_AddRefed<Request>Constructor(constGlobalObject&aGlobal,constRequestOrUSVString&aInput,constRequestInit&aInit,ErrorResult&rv);nsIGlobalObject*GetParentObject()const{returnmOwner;}already_AddRefed<Request>Clone(ErrorResult&aRv)const;already_AddRefed<InternalRequest>GetInternalRequest();private:~Request();nsCOMPtr<nsIGlobalObject>mOwner;nsRefPtr<InternalRequest>mRequest;// Lazily created.nsRefPtr<Headers>mHeaders;RequestContextmContext;};}// namespace dom}// namespace mozilla#endif // mozilla_dom_Request_h