|
5 | 5 | #include "blob.h" |
6 | 6 | #include "streams.h" |
7 | 7 | #include "util.h" |
| 8 | +#include <workerd/io/observer.h> |
8 | 9 | #include <workerd/util/mimetype.h> |
9 | 10 |
|
10 | 11 | namespace workerd::api { |
@@ -90,6 +91,11 @@ jsg::Ref<Blob> Blob::constructor(jsg::Optional<Bits> bits, jsg::Optional<Options |
90 | 91 | return jsg::alloc<Blob>(concat(kj::mv(bits)), kj::mv(type)); |
91 | 92 | } |
92 | 93 |
|
| 94 | +kj::ArrayPtr<const byte> Blob::getData() const { |
| 95 | + FeatureObserver::maybeRecordUse(FeatureObserver::Feature::BLOB_GET_DATA); |
| 96 | + return data; |
| 97 | +} |
| 98 | + |
93 | 99 | jsg::Ref<Blob> Blob::slice(jsg::Optional<int> maybeStart, jsg::Optional<int> maybeEnd, |
94 | 100 | jsg::Optional<kj::String> type) { |
95 | 101 | int start = maybeStart.orDefault(0); |
@@ -123,9 +129,11 @@ jsg::Ref<Blob> Blob::slice(jsg::Optional<int> maybeStart, jsg::Optional<int> may |
123 | 129 |
|
124 | 130 | jsg::Promise<kj::Array<kj::byte>> Blob::arrayBuffer(jsg::Lock& js) { |
125 | 131 | // TODO(perf): Find a way to avoid the copy. |
| 132 | + FeatureObserver::maybeRecordUse(FeatureObserver::Feature::BLOB_AS_ARRAY_BUFFER); |
126 | 133 | return js.resolvedPromise(kj::heapArray<byte>(data)); |
127 | 134 | } |
128 | 135 | jsg::Promise<kj::String> Blob::text(jsg::Lock& js) { |
| 136 | + FeatureObserver::maybeRecordUse(FeatureObserver::Feature::BLOB_AS_TEXT); |
129 | 137 | return js.resolvedPromise(kj::str(data.asChars())); |
130 | 138 | } |
131 | 139 |
|
@@ -185,6 +193,7 @@ private: |
185 | 193 | }; |
186 | 194 |
|
187 | 195 | jsg::Ref<ReadableStream> Blob::stream() { |
| 196 | + FeatureObserver::maybeRecordUse(FeatureObserver::Feature::BLOB_AS_STREAM); |
188 | 197 | return jsg::alloc<ReadableStream>( |
189 | 198 | IoContext::current(), |
190 | 199 | kj::heap<BlobInputStream>(JSG_THIS)); |
|
0 commit comments