Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2021-08-07 05:26:37 +0300
committerJames M Snell <jasnell@gmail.com>2021-08-12 17:23:15 +0300
commit31d1d0c4c19fea5007eb8c55a4cb1178f295c8ca (patch)
tree952dace5c1d443f62208be2e1bcd5abe7dfa783e /src/node_blob.h
parent793c08b8d1b9b1f639e74bf7289acb8fb01b1765 (diff)
url,buffer: implement URL.createObjectURL
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/39693 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Diffstat (limited to 'src/node_blob.h')
-rw-r--r--src/node_blob.h56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/node_blob.h b/src/node_blob.h
index 9d6178996c8..61f4da655c9 100644
--- a/src/node_blob.h
+++ b/src/node_blob.h
@@ -8,9 +8,12 @@
#include "env.h"
#include "memory_tracker.h"
#include "node_internals.h"
+#include "node_snapshotable.h"
#include "node_worker.h"
#include "v8.h"
+#include <string>
+#include <unordered_map>
#include <vector>
namespace node {
@@ -25,11 +28,19 @@ class Blob : public BaseObject {
public:
static void RegisterExternalReferences(
ExternalReferenceRegistry* registry);
- static void Initialize(Environment* env, v8::Local<v8::Object> target);
+
+ static void Initialize(
+ v8::Local<v8::Object> target,
+ v8::Local<v8::Value> unused,
+ v8::Local<v8::Context> context,
+ void* priv);
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void ToArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args);
static void ToSlice(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void StoreDataObject(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void GetDataObject(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void RevokeDataObject(const v8::FunctionCallbackInfo<v8::Value>& args);
static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
Environment* env);
@@ -131,6 +142,49 @@ class FixedSizeBlobCopyJob : public AsyncWrap, public ThreadPoolWork {
size_t length_ = 0;
};
+class BlobBindingData : public SnapshotableObject {
+ public:
+ explicit BlobBindingData(Environment* env, v8::Local<v8::Object> wrap);
+
+ SERIALIZABLE_OBJECT_METHODS()
+
+ static constexpr FastStringKey type_name{"node::BlobBindingData"};
+ static constexpr EmbedderObjectType type_int =
+ EmbedderObjectType::k_blob_binding_data;
+
+ void MemoryInfo(MemoryTracker* tracker) const override;
+ SET_SELF_SIZE(BlobBindingData)
+ SET_MEMORY_INFO_NAME(BlobBindingData)
+
+ struct StoredDataObject : public MemoryRetainer {
+ BaseObjectPtr<Blob> blob;
+ size_t length;
+ std::string type;
+
+ StoredDataObject() = default;
+
+ StoredDataObject(
+ const BaseObjectPtr<Blob>& blob_,
+ size_t length_,
+ const std::string& type_);
+
+ void MemoryInfo(MemoryTracker* tracker) const override;
+ SET_SELF_SIZE(StoredDataObject)
+ SET_MEMORY_INFO_NAME(StoredDataObject)
+ };
+
+ void store_data_object(
+ const std::string& uuid,
+ const StoredDataObject& object);
+
+ void revoke_data_object(const std::string& uuid);
+
+ StoredDataObject get_data_object(const std::string& uuid);
+
+ private:
+ std::unordered_map<std::string, StoredDataObject> data_objects_;
+};
+
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS