mirror of
https://github.com/denoland/deno.git
synced 2024-11-01 09:24:20 -04:00
966ce7de8a
This commit adds blob URL support. Blob URLs are stored in a process global storage, that can be accessed from all workers, and the module loader. Blob URLs can be created using `URL.createObjectURL` and revoked using `URL.revokeObjectURL`. This commit does not add support for `fetch`ing blob URLs. This will be added in a follow up commit.
31 lines
769 B
Rust
31 lines
769 B
Rust
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
use deno_core::url::Url;
|
|
use deno_file::op_file_create_object_url;
|
|
use deno_file::op_file_revoke_object_url;
|
|
use deno_file::BlobUrlStore;
|
|
use deno_file::Location;
|
|
|
|
pub fn init(
|
|
rt: &mut deno_core::JsRuntime,
|
|
blob_url_store: BlobUrlStore,
|
|
maybe_location: Option<Url>,
|
|
) {
|
|
{
|
|
let op_state = rt.op_state();
|
|
let mut op_state = op_state.borrow_mut();
|
|
op_state.put(blob_url_store);
|
|
if let Some(location) = maybe_location {
|
|
op_state.put(Location(location));
|
|
}
|
|
}
|
|
super::reg_json_sync(
|
|
rt,
|
|
"op_file_create_object_url",
|
|
op_file_create_object_url,
|
|
);
|
|
super::reg_json_sync(
|
|
rt,
|
|
"op_file_revoke_object_url",
|
|
op_file_revoke_object_url,
|
|
);
|
|
}
|