WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP
bug-159804-20160715164306.patch (text/plain), 5.98 KB, created by
youenn fablet
on 2016-07-15 07:43:55 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2016-07-15 07:43:55 PDT
Size:
5.98 KB
patch
obsolete
>Subversion Revision: 203270 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f42cc639fc2da212d562bfaf189a760307d0ac94..46403d4a9fc0be1906073649bceb41fef86eb024 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,5 +1,24 @@ > 2016-07-15 Youenn Fablet <youenn@apple.com> > >+ [Fetch API] Response constructor should be able to take a ReadableStream as body >+ https://bugs.webkit.org/show_bug.cgi?id=159804 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests to be added. >+ >+ * Modules/fetch/FetchResponse.cpp: >+ (WebCore::FetchResponse::cloneForJS): clone everything except the ReadableStream. >+ (WebCore::FetchResponse::clone): Deleted. >+ * Modules/fetch/FetchResponse.h: Adding cloneForJS. >+ * Modules/fetch/FetchResponse.idl: Ditto. >+ * Modules/fetch/FetchResponse.js: >+ (initializeFetchResponse): Storing body in @body if it is a ReadableStream >+ (clone): Adding cloning of ReadableStream if any to regular cloning done by cloneForJS. >+ * bindings/js/WebCoreBuiltinNames.h: Adding cloneForJS identifier. >+ >+2016-07-15 Youenn Fablet <youenn@apple.com> >+ > Use a private property to implement FetchResponse.body getter > https://bugs.webkit.org/show_bug.cgi?id=159808 > >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.cpp b/Source/WebCore/Modules/fetch/FetchResponse.cpp >index 5fe6460e5782387ce153284023bd344bdb4633e3..ae3c6a9fe10fb44734c673dea9339364b91ed890 100644 >--- a/Source/WebCore/Modules/fetch/FetchResponse.cpp >+++ b/Source/WebCore/Modules/fetch/FetchResponse.cpp >@@ -118,13 +118,11 @@ FetchResponse::FetchResponse(ScriptExecutionContext& context, FetchBody&& body, > { > } > >-RefPtr<FetchResponse> FetchResponse::clone(ScriptExecutionContext& context, ExceptionCode& ec) >+Ref<FetchResponse> FetchResponse::cloneForJS() > { >- if (isDisturbed()) { >- ec = TypeError; >- return nullptr; >- } >- return adoptRef(*new FetchResponse(context, FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response))); >+ ASSERT(scriptExecutionContext()); >+ ASSERT(!isDisturbed()); >+ return adoptRef(*new FetchResponse(*scriptExecutionContext(), FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response))); > } > > void FetchResponse::startFetching(ScriptExecutionContext& context, const FetchRequest& request, FetchPromise&& promise) >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.h b/Source/WebCore/Modules/fetch/FetchResponse.h >index 36d8508a0c7570beb286754ff3e705d0e20883e3..24e144e940999248bf8f5282870c51a6f20067ea 100644 >--- a/Source/WebCore/Modules/fetch/FetchResponse.h >+++ b/Source/WebCore/Modules/fetch/FetchResponse.h >@@ -68,7 +68,7 @@ public: > const String& statusText() const { return m_response.httpStatusText(); } > > FetchHeaders& headers() { return m_headers; } >- RefPtr<FetchResponse> clone(ScriptExecutionContext&, ExceptionCode&); >+ Ref<FetchResponse> cloneForJS(); > > #if ENABLE(STREAMS_API) > ReadableStreamSource* createReadableStreamSource(); >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.idl b/Source/WebCore/Modules/fetch/FetchResponse.idl >index f868b29b23c4e148a1cf4e55f8d090bbc5b51880..434e80d31add9aa415212d4dfe4347786edc0810 100644 >--- a/Source/WebCore/Modules/fetch/FetchResponse.idl >+++ b/Source/WebCore/Modules/fetch/FetchResponse.idl >@@ -53,8 +53,9 @@ interface FetchResponse { > readonly attribute FetchHeaders headers; > [JSBuiltin] readonly attribute ReadableStream? body; > >- [NewObject, CallWith=ScriptExecutionContext, RaisesException] FetchResponse clone(); >+ [JSBuiltin] FetchResponse clone(); > >+ [PrivateIdentifier, NewObject] FetchResponse cloneForJS(); > [PrivateIdentifier, RaisesException] void initializeWith(Dictionary parameters); > [PrivateIdentifier, NewObject] ReadableStreamSource createReadableStreamSource(); > [PrivateIdentifier] boolean isDisturbed(); >diff --git a/Source/WebCore/Modules/fetch/FetchResponse.js b/Source/WebCore/Modules/fetch/FetchResponse.js >index 3e3ea07f1589ffd2bc6859e2f5b1d70850b2ead4..b51ccedaa1fb2418b9c6a8318f7ff96562701161 100644 >--- a/Source/WebCore/Modules/fetch/FetchResponse.js >+++ b/Source/WebCore/Modules/fetch/FetchResponse.js >@@ -44,10 +44,20 @@ function initializeFetchResponse(body, init) > if (parameters.statusText === @undefined) > parameters.statusText = "OK"; > >- if (body !== @undefined && body !== null) >- parameters.body = body; >+ >+ var isBodyReadableStream = false; >+ if (body !== @undefined && body !== null) { >+ // We use that check because @ReadableStream is compiled-guarded. >+ isBodyReadableStream = (@isObject(body) && !!body.@underlyingSource); >+ if (!isBodyReadableStream) >+ parameters.body = body; >+ } > > this.@initializeWith(parameters); >+ >+ if (isBodyReadableStream) >+ this.@body = body; >+ > return this; > } > >@@ -65,3 +75,20 @@ function body() > } > return this.@body; > } >+ >+function clone() >+{ >+ if (!this instanceof @Response) >+ throw new @TypeError("Function should be called on a Response"); >+ >+ if (@Response.prototype.@isDisturbed.@call(this)) >+ throw new @TypeError("Cannot clone a disturbed Response"); >+ >+ var cloned = @Response.prototype.@cloneForJS.@call(this); >+ if (this.@body) { >+ var teedReadableStreams = @teeReadableStream(this.@body, false); >+ this.@body = teedReadableStreams[0]; >+ cloned.@body = teedReadableStreams[1]; >+ } >+ return cloned; >+} >diff --git a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >index 037a2946baa875fb9f8a5bcb3b8537c1b85d05e8..4f79e0402b5172f0584d41ca6ed47578aaaf1f68 100644 >--- a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >+++ b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h >@@ -52,6 +52,7 @@ namespace WebCore { > macro(localStreams) \ > macro(operations) \ > macro(ownerReadableStream) \ >+ macro(cloneForJS) \ > macro(privateGetStats) \ > macro(pulling) \ > macro(pullAgain) \
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 159804
:
283761
|
284484
|
284485
|
284486
|
284492
|
284493
|
284498
|
284522
|
284592
|
284603