11cb0ef41Sopenharmony_ci#ifndef SRC_NODE_WASM_WEB_API_H_ 21cb0ef41Sopenharmony_ci#define SRC_NODE_WASM_WEB_API_H_ 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci#include "base_object-inl.h" 71cb0ef41Sopenharmony_ci#include "v8.h" 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_cinamespace node { 101cb0ef41Sopenharmony_cinamespace wasm_web_api { 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci// Wrapper for interacting with a v8::WasmStreaming instance from JavaScript. 131cb0ef41Sopenharmony_ciclass WasmStreamingObject final : public BaseObject { 141cb0ef41Sopenharmony_ci public: 151cb0ef41Sopenharmony_ci static v8::Local<v8::Function> Initialize(Environment* env); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci static void RegisterExternalReferences(ExternalReferenceRegistry* registry); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci void MemoryInfo(MemoryTracker* tracker) const override; 201cb0ef41Sopenharmony_ci SET_MEMORY_INFO_NAME(WasmStreamingObject) 211cb0ef41Sopenharmony_ci SET_SELF_SIZE(WasmStreamingObject) 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci static v8::MaybeLocal<v8::Object> Create( 241cb0ef41Sopenharmony_ci Environment* env, std::shared_ptr<v8::WasmStreaming> streaming); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci private: 271cb0ef41Sopenharmony_ci WasmStreamingObject(Environment* env, v8::Local<v8::Object> object) 281cb0ef41Sopenharmony_ci : BaseObject(env, object) { 291cb0ef41Sopenharmony_ci MakeWeak(); 301cb0ef41Sopenharmony_ci } 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci ~WasmStreamingObject() override {} 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci private: 351cb0ef41Sopenharmony_ci static void New(const v8::FunctionCallbackInfo<v8::Value>& args); 361cb0ef41Sopenharmony_ci static void SetURL(const v8::FunctionCallbackInfo<v8::Value>& args); 371cb0ef41Sopenharmony_ci static void Push(const v8::FunctionCallbackInfo<v8::Value>& args); 381cb0ef41Sopenharmony_ci static void Finish(const v8::FunctionCallbackInfo<v8::Value>& args); 391cb0ef41Sopenharmony_ci static void Abort(const v8::FunctionCallbackInfo<v8::Value>& args); 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci std::shared_ptr<v8::WasmStreaming> streaming_; 421cb0ef41Sopenharmony_ci size_t wasm_size_ = 0; 431cb0ef41Sopenharmony_ci}; 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci// This is a v8::WasmStreamingCallback implementation that must be passed to 461cb0ef41Sopenharmony_ci// v8::Isolate::SetWasmStreamingCallback when setting up the isolate in order to 471cb0ef41Sopenharmony_ci// enable the WebAssembly.(compile|instantiate)Streaming APIs. 481cb0ef41Sopenharmony_civoid StartStreamingCompilation(const v8::FunctionCallbackInfo<v8::Value>& args); 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ci} // namespace wasm_web_api 511cb0ef41Sopenharmony_ci} // namespace node 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci#endif // SRC_NODE_WASM_WEB_API_H_ 56