author | Ben Kelly <ben@wanderview.com> |
Tue, 12 Jan 2016 12:15:12 -0800 | |
changeset 314776 | d0b39a33e04200fade4553f4cb5d72187b282bee |
parent 314775 | ec4ff5db95592903dc9a8c3ad374eb99c540c468 |
child 314777 | b12cc3b2697b8c004f2c2c22fca8b15473e74dcf |
push id | 5703 |
push user | raliiev@mozilla.com |
push date | Mon, 07 Mar 2016 14:18:41 +0000 |
treeherder | mozilla-beta@31e373ad5b5f [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ehsan |
bugs | 1238134 |
milestone | 46.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/fetch/InternalResponse.cpp +++ b/dom/fetch/InternalResponse.cpp @@ -127,16 +127,26 @@ InternalResponse::GetTainting() const case ResponseType::Opaque: return LoadTainting::Opaque; default: return LoadTainting::Basic; } } already_AddRefed<InternalResponse> +InternalResponse::Unfiltered() +{ + RefPtr<InternalResponse> ref = mWrappedResponse; + if (!ref) { + ref = this; + } + return ref.forget(); +} + +already_AddRefed<InternalResponse> InternalResponse::OpaqueResponse() { MOZ_ASSERT(!mWrappedResponse, "Can't OpaqueResponse a already wrapped response"); RefPtr<InternalResponse> response = new InternalResponse(0, EmptyCString()); response->mType = ResponseType::Opaque; response->mTerminationReason = mTerminationReason; response->mChannelInfo = mChannelInfo; if (mPrincipalInfo) {
--- a/dom/fetch/InternalResponse.h +++ b/dom/fetch/InternalResponse.h @@ -216,16 +216,19 @@ public: SetPrincipalInfo(UniquePtr<mozilla::ipc::PrincipalInfo> aPrincipalInfo); nsresult StripFragmentAndSetUrl(const nsACString& aUrl); LoadTainting GetTainting() const; + already_AddRefed<InternalResponse> + Unfiltered(); + private: ~InternalResponse(); explicit InternalResponse(const InternalResponse& aOther) = delete; InternalResponse& operator=(const InternalResponse&) = delete; // Returns an instance of InternalResponse which is a copy of this // InternalResponse, except headers, body and wrapped response (if any) which
--- a/dom/fetch/Response.cpp +++ b/dom/fetch/Response.cpp @@ -233,16 +233,30 @@ Response::Clone(ErrorResult& aRv) const return nullptr; } RefPtr<InternalResponse> ir = mInternalResponse->Clone(); RefPtr<Response> response = new Response(mOwner, ir); return response.forget(); } +already_AddRefed<Response> +Response::CloneUnfiltered(ErrorResult& aRv) const +{ + if (BodyUsed()) { + aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>(); + return nullptr; + } + + RefPtr<InternalResponse> clone = mInternalResponse->Clone(); + RefPtr<InternalResponse> ir = clone->Unfiltered(); + RefPtr<Response> ref = new Response(mOwner, ir); + return ref.forget(); +} + void Response::SetBody(nsIInputStream* aBody) { MOZ_ASSERT(!BodyUsed()); mInternalResponse->SetBody(aBody); } already_AddRefed<InternalResponse>
--- a/dom/fetch/Response.h +++ b/dom/fetch/Response.h @@ -119,16 +119,19 @@ public: nsIGlobalObject* GetParentObject() const { return mOwner; } already_AddRefed<Response> Clone(ErrorResult& aRv) const; + already_AddRefed<Response> + CloneUnfiltered(ErrorResult& aRv) const; + void SetBody(nsIInputStream* aBody); already_AddRefed<InternalResponse> GetInternalResponse() const; private: ~Response();
--- a/dom/webidl/Response.webidl +++ b/dom/webidl/Response.webidl @@ -19,16 +19,18 @@ interface Response { readonly attribute USVString url; readonly attribute unsigned short status; readonly attribute boolean ok; readonly attribute ByteString statusText; [SameObject] readonly attribute Headers headers; [Throws, NewObject] Response clone(); + + [ChromeOnly, NewObject, Throws] Response cloneUnfiltered(); }; Response implements Body; dictionary ResponseInit { unsigned short status = 200; // WebIDL spec doesn't allow default values for ByteString. ByteString statusText; HeadersInit headers;