2014-07-25 04:53:03 +04:00
|
|
|
/* -*- 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
|
|
|
|
|
2015-01-28 02:43:09 +03:00
|
|
|
#include "nsIContentPolicy.h"
|
2014-07-25 04:53:03 +04:00
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
2014-09-27 03:41:15 +04:00
|
|
|
#include "mozilla/dom/Fetch.h"
|
2014-09-24 09:03:20 +04:00
|
|
|
#include "mozilla/dom/InternalRequest.h"
|
|
|
|
// Required here due to certain WebIDL enums/classes being declared in both
|
|
|
|
// files.
|
2014-07-25 04:53:03 +04:00
|
|
|
#include "mozilla/dom/RequestBinding.h"
|
|
|
|
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Headers;
|
2014-10-02 21:59:20 +04:00
|
|
|
class InternalHeaders;
|
2014-07-25 04:53:03 +04:00
|
|
|
class Promise;
|
2014-11-20 14:58:00 +03:00
|
|
|
class RequestOrUSVString;
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class Request final : public nsISupports
|
2015-03-27 21:52:19 +03:00
|
|
|
, public FetchBody<Request>
|
|
|
|
, public nsWrapperCache
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Request)
|
|
|
|
|
|
|
|
public:
|
2014-09-24 09:03:20 +04:00
|
|
|
Request(nsIGlobalObject* aOwner, InternalRequest* aRequest);
|
2014-07-25 04:53:03 +04:00
|
|
|
|
|
|
|
JSObject*
|
2015-03-21 19:28:04 +03:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return RequestBinding::Wrap(aCx, this, aGivenProto);
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-03-02 16:08:00 +03:00
|
|
|
GetUrl(nsAString& aUrl) const
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
2015-03-02 16:08:00 +03:00
|
|
|
CopyUTF8toUTF16(mRequest->mURL, aUrl);
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetMethod(nsCString& aMethod) const
|
|
|
|
{
|
2014-09-24 09:03:20 +04:00
|
|
|
aMethod = mRequest->mMethod;
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
RequestMode
|
|
|
|
Mode() const
|
|
|
|
{
|
2015-01-08 03:24:40 +03:00
|
|
|
if (mRequest->mMode == RequestMode::Cors_with_forced_preflight) {
|
|
|
|
return RequestMode::Cors;
|
|
|
|
}
|
2014-09-24 09:03:20 +04:00
|
|
|
return mRequest->mMode;
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
RequestCredentials
|
|
|
|
Credentials() const
|
|
|
|
{
|
2014-09-24 09:03:20 +04:00
|
|
|
return mRequest->mCredentialsMode;
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
2015-01-08 03:24:40 +03:00
|
|
|
RequestCache
|
|
|
|
Cache() const
|
|
|
|
{
|
|
|
|
return mRequest->GetCacheMode();
|
|
|
|
}
|
|
|
|
|
2015-01-28 02:43:09 +03:00
|
|
|
RequestContext
|
|
|
|
Context() const
|
|
|
|
{
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
2015-01-28 03:02:12 +03:00
|
|
|
// [ChromeOnly]
|
|
|
|
void
|
|
|
|
SetContext(RequestContext aContext)
|
|
|
|
{
|
|
|
|
mContext = aContext;
|
|
|
|
}
|
|
|
|
|
2014-07-25 04:53:03 +04:00
|
|
|
void
|
2014-12-23 18:56:19 +03:00
|
|
|
GetReferrer(nsAString& aReferrer) const
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
2014-12-23 18:56:19 +03:00
|
|
|
mRequest->GetReferrer(aReferrer);
|
2014-07-25 04:53:03 +04:00
|
|
|
}
|
|
|
|
|
2014-10-02 21:59:20 +04:00
|
|
|
InternalHeaders*
|
|
|
|
GetInternalHeaders() const
|
|
|
|
{
|
|
|
|
return mRequest->Headers();
|
|
|
|
}
|
|
|
|
|
|
|
|
Headers* Headers_();
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2014-09-27 03:41:15 +04:00
|
|
|
void
|
|
|
|
GetBody(nsIInputStream** aStream) { return mRequest->GetBody(aStream); }
|
|
|
|
|
2014-07-25 04:53:03 +04:00
|
|
|
static already_AddRefed<Request>
|
2014-11-20 14:58:00 +03:00
|
|
|
Constructor(const GlobalObject& aGlobal, const RequestOrUSVString& aInput,
|
2014-07-25 04:53:03 +04:00
|
|
|
const RequestInit& aInit, ErrorResult& rv);
|
|
|
|
|
2014-09-27 03:41:15 +04:00
|
|
|
nsIGlobalObject* GetParentObject() const
|
2014-07-25 04:53:03 +04:00
|
|
|
{
|
|
|
|
return mOwner;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Request>
|
2015-02-20 04:24:24 +03:00
|
|
|
Clone(ErrorResult& aRv) const;
|
2014-07-25 04:53:03 +04:00
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
already_AddRefed<InternalRequest>
|
|
|
|
GetInternalRequest();
|
2014-07-25 04:53:03 +04:00
|
|
|
private:
|
|
|
|
~Request();
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
nsCOMPtr<nsIGlobalObject> mOwner;
|
|
|
|
nsRefPtr<InternalRequest> mRequest;
|
2014-10-02 21:59:20 +04:00
|
|
|
// Lazily created.
|
|
|
|
nsRefPtr<Headers> mHeaders;
|
2015-01-28 02:43:09 +03:00
|
|
|
RequestContext mContext;
|
2014-07-25 04:53:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_Request_h
|