Commit 832e5b9f authored by Mircea Trofin's avatar Mircea Trofin Committed by Commit Bot

[wasm] Add an explicit Abort to wasm streaming builder.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Iae6942cf2b223a296dda479af26a978576d0c58a
Reviewed-on: https://chromium-review.googlesource.com/584367Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Mircea Trofin <mtrofin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46882}
parent f1f22857
......@@ -4169,11 +4169,7 @@ class V8_EXPORT WasmModuleObjectBuilderStreaming final {
// The buffer passed into OnBytesReceived is owned by the caller.
void OnBytesReceived(const uint8_t*, size_t size);
void Finish();
// Currently, we don't need an explicit Abort, because there's no
// activity happening until Finish is called. Should the connection
// be dropped, for example, the network layer is expected to reject
// the promise and then this object is destroyed, which, at the moment,
// just means the {received_buffers_} are freed.
void Abort(Local<Value> exception);
private:
typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> Buffer;
......
......@@ -7846,6 +7846,16 @@ void WasmModuleObjectBuilderStreaming::Finish() {
{wire_bytes.get(), wire_bytes.get() + total_size_});
}
void WasmModuleObjectBuilderStreaming::Abort(Local<Value> exception) {
Local<Promise::Resolver> resolver =
promise_.Get(isolate_).As<Promise::Resolver>();
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate_);
i::HandleScope scope(i_isolate);
Local<Context> context = Utils::ToLocal(handle(i_isolate->context()));
auto maybe = resolver->Reject(context, exception);
CHECK_IMPLIES(!maybe.FromMaybe(false), i_isolate->has_scheduled_exception());
}
void WasmModuleObjectBuilder::OnBytesReceived(const uint8_t* bytes,
size_t size) {
std::unique_ptr<uint8_t[]> cloned_bytes(new uint8_t[size]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment