| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef Response_h | 5 #ifndef Response_h |
| 6 #define Response_h | 6 #define Response_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
| 9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
| 11 #include "modules/ModulesExport.h" | 11 #include "modules/ModulesExport.h" |
| 12 #include "modules/fetch/Body.h" | 12 #include "modules/fetch/Body.h" |
| 13 #include "modules/fetch/BodyStreamBuffer.h" | 13 #include "modules/fetch/BodyStreamBuffer.h" |
| 14 #include "modules/fetch/FetchResponseData.h" | 14 #include "modules/fetch/FetchResponseData.h" |
| 15 #include "modules/fetch/Headers.h" | 15 #include "modules/fetch/Headers.h" |
| 16 #include "platform/blob/BlobData.h" | 16 #include "platform/blob/BlobData.h" |
| 17 #include "platform/heap/Handle.h" | 17 #include "platform/heap/Handle.h" |
| 18 #include "wtf/Vector.h" | 18 #include "wtf/Vector.h" |
| 19 #include "wtf/text/WTFString.h" | 19 #include "wtf/text/WTFString.h" |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 class ExceptionState; | 23 class ExceptionState; |
| 24 class ResponseInit; | 24 class ResponseInit; |
| 25 class ScriptState; | 25 class ScriptState; |
| 26 class WebServiceWorkerResponse; | 26 class WebServiceWorkerResponse; |
| 27 | 27 |
| 28 class MODULES_EXPORT Response final : public Body { | 28 class MODULES_EXPORT Response final : public Body { |
| 29 DEFINE_WRAPPERTYPEINFO(); | 29 public: |
| 30 const WrapperTypeInfo* wrapperTypeInfo() const override { |
| 31 return &s_wrapperTypeInfoOverride; |
| 32 } |
| 33 |
| 34 private: |
| 35 // We want to overload in blink V8-provided APIs - namely, WebAssembly.compile |
| 36 // and WebAssembly.instantiate. Refer to: |
| 37 // https://github.com/WebAssembly/design/blob/master/Web.md#additional-web-emb
edding-api |
| 38 // |
| 39 // The overloads need to be implemented blink-side because they work with web |
| 40 // APIs (Response). To achieve this, we use purposefully-built injection |
| 41 // points exposed by V8 and initialize them when the Response APIs are |
| 42 // initialized. At the moment, this requires working around the generated |
| 43 // code: we redefine the WrapperTypeInfo and insert the installerOveride, |
| 44 // which injects the overloads and then continues with the usual |
| 45 // initialization. |
| 46 // |
| 47 // https://crbug.com/708238 for tracking. |
| 48 static v8::Local<v8::FunctionTemplate> installerOverride( |
| 49 v8::Isolate*, |
| 50 const DOMWrapperWorld&); |
| 51 static const WrapperTypeInfo& s_wrapperTypeInfo; |
| 52 static const WrapperTypeInfo s_wrapperTypeInfoOverride; |
| 53 |
| 30 WTF_MAKE_NONCOPYABLE(Response); | 54 WTF_MAKE_NONCOPYABLE(Response); |
| 31 | 55 |
| 32 public: | 56 public: |
| 33 // These "create" function which takes a ScriptState* must be called with | 57 // These "create" function which takes a ScriptState* must be called with |
| 34 // entering an appropriate V8 context. | 58 // entering an appropriate V8 context. |
| 35 // From Response.idl: | 59 // From Response.idl: |
| 36 static Response* create(ScriptState*, ExceptionState&); | 60 static Response* create(ScriptState*, ExceptionState&); |
| 37 static Response* create(ScriptState*, | 61 static Response* create(ScriptState*, |
| 38 ScriptValue body, | 62 ScriptValue body, |
| 39 const ResponseInit&, | 63 const ResponseInit&, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 void installBody(); | 133 void installBody(); |
| 110 void refreshBody(ScriptState*); | 134 void refreshBody(ScriptState*); |
| 111 | 135 |
| 112 const Member<FetchResponseData> m_response; | 136 const Member<FetchResponseData> m_response; |
| 113 const Member<Headers> m_headers; | 137 const Member<Headers> m_headers; |
| 114 }; | 138 }; |
| 115 | 139 |
| 116 } // namespace blink | 140 } // namespace blink |
| 117 | 141 |
| 118 #endif // Response_h | 142 #endif // Response_h |
| OLD | NEW |