Skip to content

Commit

Permalink
Merge pull request #897 from cloudflare/jsnell/jsg-completion-avoid-i…
Browse files Browse the repository at this point in the history
…solate-in-blob
  • Loading branch information
jasnell committed Jul 24, 2023
2 parents 404d6bb + 5f06b26 commit b1750f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/workerd/api/blob.c++
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ jsg::Ref<Blob> Blob::slice(jsg::Optional<int> maybeStart, jsg::Optional<int> may
normalizeType(kj::mv(type).orDefault(nullptr)));
}

jsg::Promise<kj::Array<kj::byte>> Blob::arrayBuffer(v8::Isolate* isolate) {
jsg::Promise<kj::Array<kj::byte>> Blob::arrayBuffer(jsg::Lock& js) {
// TODO(perf): Find a way to avoid the copy.
return jsg::resolvedPromise(isolate, kj::heapArray<byte>(data));
return js.resolvedPromise(kj::heapArray<byte>(data));
}
jsg::Promise<kj::String> Blob::text(v8::Isolate* isolate) {
return jsg::resolvedPromise(isolate, kj::str(data.asChars()));
jsg::Promise<kj::String> Blob::text(jsg::Lock& js) {
return js.resolvedPromise(kj::str(data.asChars()));
}

class Blob::BlobInputStream final: public ReadableStreamSource {
Expand Down Expand Up @@ -192,7 +192,7 @@ private:
jsg::Ref<Blob> blob;
};

jsg::Ref<ReadableStream> Blob::stream(v8::Isolate* isolate) {
jsg::Ref<ReadableStream> Blob::stream() {
return jsg::alloc<ReadableStream>(
IoContext::current(),
kj::heap<BlobInputStream>(JSG_THIS));
Expand Down
6 changes: 3 additions & 3 deletions src/workerd/api/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class Blob: public jsg::Object {
jsg::Ref<Blob> slice(jsg::Optional<int> start, jsg::Optional<int> end,
jsg::Optional<kj::String> type);

jsg::Promise<kj::Array<kj::byte>> arrayBuffer(v8::Isolate* isolate);
jsg::Promise<kj::String> text(v8::Isolate* isolate);
jsg::Ref<ReadableStream> stream(v8::Isolate* isolate);
jsg::Promise<kj::Array<kj::byte>> arrayBuffer(jsg::Lock& js);
jsg::Promise<kj::String> text(jsg::Lock& js);
jsg::Ref<ReadableStream> stream();

JSG_RESOURCE_TYPE(Blob, CompatibilityFlags::Reader flags) {
if (flags.getJsgPropertyOnPrototypeTemplate()) {
Expand Down

0 comments on commit b1750f7

Please sign in to comment.