Changeset 197744 in webkit
- Timestamp:
- Mar 8, 2016 1:10:09 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r197738 r197744 1 2016-03-08 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 [Fetch API] Make FetchRequest and FetchResponse ActiveDOMObject 4 https://bugs.webkit.org/show_bug.cgi?id=154729 5 6 Reviewed by Darin Adler. 7 8 Covered by existing tests. 9 10 Making FetchRequest and FetchResponse ActiveDOMObject. 11 Both objects can always be suspended now. 12 This might be updated when blob conversion is added or when fetching data to fill in FetchResponse. 13 14 * Modules/fetch/FetchRequest.cpp: 15 (WebCore::FetchRequest::create): 16 (WebCore::FetchRequest::clone): 17 (WebCore::FetchRequest::activeDOMObjectName): 18 (WebCore::FetchRequest::canSuspendForDocumentSuspension): 19 * Modules/fetch/FetchRequest.h: 20 (WebCore::FetchRequest::FetchRequest): 21 * Modules/fetch/FetchRequest.idl: 22 * Modules/fetch/FetchResponse.cpp: 23 (WebCore::FetchResponse::error): 24 (WebCore::FetchResponse::redirect): 25 (WebCore::FetchResponse::FetchResponse): 26 (WebCore::FetchResponse::clone): 27 (WebCore::FetchResponse::activeDOMObjectName): 28 (WebCore::FetchResponse::canSuspendForDocumentSuspension): 29 * Modules/fetch/FetchResponse.h: 30 (WebCore::FetchResponse::create): 31 * Modules/fetch/FetchResponse.idl: 32 1 33 2016-03-08 Nikos Andronikos <nikos.andronikos-webkit@cisra.canon.com.au> 2 34 -
trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp
r197347 r197744 267 267 } 268 268 269 return adoptRef(*new FetchRequest( WTFMove(body), headers.releaseNonNull(), WTFMove(internalRequest)));269 return adoptRef(*new FetchRequest(context, WTFMove(body), headers.releaseNonNull(), WTFMove(internalRequest))); 270 270 } 271 271 … … 298 298 } 299 299 300 return adoptRef(*new FetchRequest( WTFMove(body), headers.releaseNonNull(), WTFMove(internalRequest)));300 return adoptRef(*new FetchRequest(context, WTFMove(body), headers.releaseNonNull(), WTFMove(internalRequest))); 301 301 } 302 302 … … 436 436 } 437 437 438 RefPtr<FetchRequest> FetchRequest::clone( ExceptionCode& ec)438 RefPtr<FetchRequest> FetchRequest::clone(ScriptExecutionContext* context, ExceptionCode& ec) 439 439 { 440 440 if (isDisturbed()) { … … 444 444 445 445 // FIXME: Validate body teeing. 446 return adoptRef(*new FetchRequest(FetchBody(m_body), FetchHeaders::create(m_headers.get()), FetchRequest::InternalRequest(m_internalRequest))); 446 return adoptRef(*new FetchRequest(*context, FetchBody(m_body), FetchHeaders::create(m_headers.get()), FetchRequest::InternalRequest(m_internalRequest))); 447 } 448 449 const char* FetchRequest::activeDOMObjectName() const 450 { 451 return "Request"; 452 } 453 454 bool FetchRequest::canSuspendForDocumentSuspension() const 455 { 456 return true; 447 457 } 448 458 -
trunk/Source/WebCore/Modules/fetch/FetchRequest.h
r195954 r197744 32 32 #if ENABLE(FETCH_API) 33 33 34 #include "ActiveDOMObject.h" 34 35 #include "FetchBody.h" 35 36 #include "FetchHeaders.h" … … 44 45 typedef int ExceptionCode; 45 46 46 class FetchRequest : public RefCounted<FetchRequest>{47 class FetchRequest final : public RefCounted<FetchRequest>, public ActiveDOMObject { 47 48 public: 48 49 static RefPtr<FetchRequest> create(ScriptExecutionContext&, FetchRequest*, const Dictionary&, ExceptionCode&); … … 64 65 const String& integrity() const { return m_internalRequest.integrity; } 65 66 66 RefPtr<FetchRequest> clone( ExceptionCode&);67 RefPtr<FetchRequest> clone(ScriptExecutionContext*, ExceptionCode&); 67 68 68 69 // Body API … … 84 85 85 86 private: 86 FetchRequest(FetchBody&&, Ref<FetchHeaders>&&, InternalRequest&&); 87 FetchRequest(ScriptExecutionContext&, FetchBody&&, Ref<FetchHeaders>&&, InternalRequest&&); 88 89 // ActiveDOMObject API. 90 const char* activeDOMObjectName() const final; 91 bool canSuspendForDocumentSuspension() const final; 87 92 88 93 FetchBody m_body; … … 91 96 }; 92 97 93 inline FetchRequest::FetchRequest(FetchBody&& body, Ref<FetchHeaders>&& headers, InternalRequest&& internalRequest) 94 : m_body(WTFMove(body)) 98 inline FetchRequest::FetchRequest(ScriptExecutionContext& context, FetchBody&& body, Ref<FetchHeaders>&& headers, InternalRequest&& internalRequest) 99 : ActiveDOMObject(&context) 100 , m_body(WTFMove(body)) 95 101 , m_headers(WTFMove(headers)) 96 102 , m_internalRequest(WTFMove(internalRequest)) 97 103 { 104 suspendIfNeeded(); 98 105 } 99 106 -
trunk/Source/WebCore/Modules/fetch/FetchRequest.idl
r195954 r197744 36 36 37 37 [ 38 ActiveDOMObject, 38 39 Conditional=FETCH_API, 39 40 ConstructorCallWith=ScriptExecutionContext, … … 42 43 Constructor(DOMString input, [Default=Undefined] optional Dictionary init), 43 44 GlobalContext=DOMWindow&WorkerGlobalScope, 44 ImplementationLacksVTable,45 45 InterfaceName=Request 46 46 ] … … 60 60 readonly attribute DOMString integrity; 61 61 62 [ RaisesException, NewObject] FetchRequest clone();62 [NewObject, CallWith=ScriptExecutionContext, RaisesException] FetchRequest clone(); 63 63 }; 64 64 FetchRequest implements FetchBody; -
trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp
r197347 r197744 49 49 } 50 50 51 Ref<FetchResponse> FetchResponse::error( )51 Ref<FetchResponse> FetchResponse::error(ScriptExecutionContext* context) 52 52 { 53 return adoptRef(*new FetchResponse( Type::Error, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));53 return adoptRef(*new FetchResponse(*context, Type::Error, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse())); 54 54 } 55 55 … … 66 66 return nullptr; 67 67 } 68 RefPtr<FetchResponse> redirectResponse = adoptRef(*new FetchResponse( Type::Default, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));68 RefPtr<FetchResponse> redirectResponse = adoptRef(*new FetchResponse(*context, Type::Default, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse())); 69 69 redirectResponse->m_response.setHTTPStatusCode(status); 70 70 redirectResponse->m_headers->fastSet(HTTPHeaderName::Location, requestURL.string()); … … 109 109 } 110 110 111 FetchResponse::FetchResponse(Type type, FetchBody&& body, Ref<FetchHeaders>&& headers, ResourceResponse&& response) 112 : m_type(type) 111 FetchResponse::FetchResponse(ScriptExecutionContext& context, Type type, FetchBody&& body, Ref<FetchHeaders>&& headers, ResourceResponse&& response) 112 : ActiveDOMObject(&context) 113 , m_type(type) 113 114 , m_response(WTFMove(response)) 114 115 , m_body(WTFMove(body)) 115 116 , m_headers(WTFMove(headers)) 116 117 { 118 suspendIfNeeded(); 117 119 } 118 120 119 RefPtr<FetchResponse> FetchResponse::clone( ExceptionCode& ec)121 RefPtr<FetchResponse> FetchResponse::clone(ScriptExecutionContext* context, ExceptionCode& ec) 120 122 { 121 123 if (m_body.isDisturbed() || m_isLocked) { … … 123 125 return nullptr; 124 126 } 125 RefPtr<FetchResponse> cloned = adoptRef(*new FetchResponse( m_type, FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response)));127 RefPtr<FetchResponse> cloned = adoptRef(*new FetchResponse(*context, m_type, FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response))); 126 128 cloned->m_isRedirected = m_isRedirected; 127 129 return cloned; … … 154 156 } 155 157 158 const char* FetchResponse::activeDOMObjectName() const 159 { 160 return "Response"; 161 } 162 163 bool FetchResponse::canSuspendForDocumentSuspension() const 164 { 165 return true; 166 } 167 156 168 } // namespace WebCore 157 169 -
trunk/Source/WebCore/Modules/fetch/FetchResponse.h
r197347 r197744 32 32 #if ENABLE(FETCH_API) 33 33 34 #include "ActiveDOMObject.h" 34 35 #include "FetchBody.h" 35 36 #include "FetchHeaders.h" … … 46 47 typedef int ExceptionCode; 47 48 48 class FetchResponse : public RefCounted<FetchResponse>{49 class FetchResponse final : public RefCounted<FetchResponse>, public ActiveDOMObject { 49 50 public: 50 static Ref<FetchResponse> create( ) { return adoptRef(*new FetchResponse(Type::Default, { }, FetchHeaders::create(FetchHeaders::Guard::Response), ResourceResponse())); }51 static Ref<FetchResponse> error( );51 static Ref<FetchResponse> create(ScriptExecutionContext& context) { return adoptRef(*new FetchResponse(context, Type::Default, { }, FetchHeaders::create(FetchHeaders::Guard::Response), ResourceResponse())); } 52 static Ref<FetchResponse> error(ScriptExecutionContext*); 52 53 static RefPtr<FetchResponse> redirect(ScriptExecutionContext*, const String&, int, ExceptionCode&); 53 54 // FIXME: Binding generator should not require below method to handle optional status parameter. … … 64 65 65 66 FetchHeaders& headers() { return m_headers; } 66 RefPtr<FetchResponse> clone( ExceptionCode&);67 RefPtr<FetchResponse> clone(ScriptExecutionContext*, ExceptionCode&); 67 68 68 69 // Body API … … 77 78 enum class Type { Basic, Cors, Default, Error, Opaque, OpaqueRedirect }; 78 79 79 FetchResponse(Type, FetchBody&&, Ref<FetchHeaders>&&, ResourceResponse&&); 80 FetchResponse(ScriptExecutionContext&, Type, FetchBody&&, Ref<FetchHeaders>&&, ResourceResponse&&); 81 82 // ActiveDOMObject API 83 const char* activeDOMObjectName() const final; 84 bool canSuspendForDocumentSuspension() const final; 80 85 81 86 Type m_type; -
trunk/Source/WebCore/Modules/fetch/FetchResponse.idl
r197049 r197744 29 29 30 30 [ 31 ActiveDOMObject, 31 32 Conditional=FETCH_API, 33 ConstructorCallWith=ScriptExecutionContext, 32 34 GlobalContext=DOMWindow&WorkerGlobalScope, 33 ImplementationLacksVTable,34 35 InterfaceName=Response, 35 36 JSBuiltinConstructor … … 37 38 interface FetchResponse { 38 39 // FIXME: NewObject does not seem to be supported for static methods. 39 static FetchResponse error();40 [ RaisesException, CallWith=ScriptExecutionContext] static FetchResponse redirect(DOMString url, optional unsigned short status = 302);40 [CallWith=ScriptExecutionContext] static FetchResponse error(); 41 [CallWith=ScriptExecutionContext, RaisesException] static FetchResponse redirect(DOMString url, optional unsigned short status = 302); 41 42 42 43 readonly attribute ResponseType type; … … 51 52 [Custom, RaisesException] readonly attribute ReadableStream? body; 52 53 53 [NewObject, RaisesException] FetchResponse clone();54 [NewObject, CallWith=ScriptExecutionContext, RaisesException] FetchResponse clone(); 54 55 55 56 [Private, RaisesException] void initializeWith(Dictionary parameters);
Note: See TracChangeset
for help on using the changeset viewer.