2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-07-25 04:53:03 +04:00
|
|
|
/* 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"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Headers;
|
2014-10-02 21:59:20 +04:00
|
|
|
class InternalHeaders;
|
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
|
|
|
|
2015-07-28 00:57:34 +03:00
|
|
|
static bool
|
|
|
|
RequestContextEnabled(JSContext* aCx, JSObject* aObj);
|
|
|
|
|
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
|
|
|
{
|
2016-05-03 04:48:40 +03:00
|
|
|
nsAutoCString url;
|
|
|
|
mRequest->GetURL(url);
|
|
|
|
CopyUTF8toUTF16(url, 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
|
|
|
|
{
|
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-09-01 00:26:29 +03:00
|
|
|
RequestRedirect
|
|
|
|
Redirect() const
|
|
|
|
{
|
|
|
|
return mRequest->GetRedirectMode();
|
|
|
|
}
|
|
|
|
|
2016-09-07 05:20:23 +03:00
|
|
|
void
|
|
|
|
GetIntegrity(nsAString& aIntegrity) const
|
|
|
|
{
|
|
|
|
aIntegrity = mRequest->GetIntegrity();
|
|
|
|
}
|
|
|
|
|
2015-01-28 02:43:09 +03:00
|
|
|
RequestContext
|
|
|
|
Context() const
|
|
|
|
{
|
2015-03-25 23:38:42 +03:00
|
|
|
return mRequest->Context();
|
2015-01-28 02:43:09 +03:00
|
|
|
}
|
2015-03-25 23:38:42 +03:00
|
|
|
|
|
|
|
void
|
2016-04-08 00:13:09 +03:00
|
|
|
OverrideContentPolicyType(nsContentPolicyType aContentPolicyType)
|
2015-03-25 23:38:42 +03:00
|
|
|
{
|
2016-04-08 00:13:09 +03:00
|
|
|
mRequest->OverrideContentPolicyType(aContentPolicyType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsContentPolicyTypeOverridden() const
|
|
|
|
{
|
|
|
|
return mRequest->IsContentPolicyTypeOverridden();
|
2015-01-28 03:02:12 +03:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-02-27 01:36:45 +03:00
|
|
|
ReferrerPolicy
|
|
|
|
ReferrerPolicy_() const
|
|
|
|
{
|
|
|
|
return mRequest->ReferrerPolicy_();
|
|
|
|
}
|
|
|
|
|
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); }
|
|
|
|
|
2015-08-10 22:06:00 +03:00
|
|
|
void
|
|
|
|
SetBody(nsIInputStream* aStream) { return mRequest->SetBody(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();
|
2016-10-26 10:07:25 +03:00
|
|
|
|
|
|
|
const UniquePtr<mozilla::ipc::PrincipalInfo>&
|
|
|
|
GetPrincipalInfo() const
|
|
|
|
{
|
|
|
|
return mRequest->GetPrincipalInfo();
|
|
|
|
}
|
|
|
|
|
2014-07-25 04:53:03 +04:00
|
|
|
private:
|
|
|
|
~Request();
|
|
|
|
|
2014-09-24 09:03:20 +04:00
|
|
|
nsCOMPtr<nsIGlobalObject> mOwner;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<InternalRequest> mRequest;
|
2014-10-02 21:59:20 +04:00
|
|
|
// Lazily created.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Headers> mHeaders;
|
2014-07-25 04:53:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_Request_h
|