mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Transfer ReadableStream (#36181)
<!-- Please describe your changes on the following line: --> Add transfer support to ReadableStream. Part of https://github.com/servo/servo/issues/34676 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> --------- Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
This commit is contained in:
parent
c9489ca04f
commit
f8b6b9f7b6
22 changed files with 983 additions and 75 deletions
|
@ -41,6 +41,7 @@ use crate::dom::dompoint::DOMPoint;
|
|||
use crate::dom::dompointreadonly::DOMPointReadOnly;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::messageport::MessagePort;
|
||||
use crate::dom::readablestream::ReadableStream;
|
||||
use crate::realms::{AlreadyInRealm, InRealm, enter_realm};
|
||||
use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
|
||||
|
||||
|
@ -57,6 +58,7 @@ pub(super) enum StructuredCloneTags {
|
|||
Principals = 0xFFFF8003,
|
||||
DomPointReadOnly = 0xFFFF8004,
|
||||
DomPoint = 0xFFFF8005,
|
||||
ReadableStream = 0xFFFF8006,
|
||||
Max = 0xFFFFFFFF,
|
||||
}
|
||||
|
||||
|
@ -74,6 +76,7 @@ impl From<TransferrableInterface> for StructuredCloneTags {
|
|||
fn from(v: TransferrableInterface) -> Self {
|
||||
match v {
|
||||
TransferrableInterface::MessagePort => StructuredCloneTags::MessagePort,
|
||||
TransferrableInterface::ReadableStream => StructuredCloneTags::ReadableStream,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,6 +253,7 @@ fn receiver_for_type(
|
|||
) -> fn(&GlobalScope, &mut StructuredDataReader, u64, RawMutableHandleObject) -> Result<(), ()> {
|
||||
match val {
|
||||
TransferrableInterface::MessagePort => receive_object::<MessagePort>,
|
||||
TransferrableInterface::ReadableStream => receive_object::<ReadableStream>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,6 +379,7 @@ type TransferOperation = unsafe fn(
|
|||
fn transfer_for_type(val: TransferrableInterface) -> TransferOperation {
|
||||
match val {
|
||||
TransferrableInterface::MessagePort => try_transfer::<MessagePort>,
|
||||
TransferrableInterface::ReadableStream => try_transfer::<ReadableStream>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,6 +426,7 @@ unsafe fn can_transfer_for_type(
|
|||
}
|
||||
match transferable {
|
||||
TransferrableInterface::MessagePort => can_transfer::<MessagePort>(obj, cx),
|
||||
TransferrableInterface::ReadableStream => can_transfer::<ReadableStream>(obj, cx),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,6 +513,7 @@ pub(crate) struct StructuredDataReader {
|
|||
pub(crate) blob_impls: Option<HashMap<BlobId, BlobImpl>>,
|
||||
/// A map of serialized points.
|
||||
pub(crate) points: Option<HashMap<DomPointId, DomPoint>>,
|
||||
pub(crate) readable_streams: Option<Vec<DomRoot<ReadableStream>>>,
|
||||
}
|
||||
|
||||
/// A data holder for transferred and serialized objects.
|
||||
|
@ -597,6 +604,7 @@ pub(crate) fn read(
|
|||
blob_impls: data.blobs.take(),
|
||||
points: data.points.take(),
|
||||
errors: DOMErrorRecord { message: None },
|
||||
readable_streams: None,
|
||||
};
|
||||
let sc_reader_ptr = &mut sc_reader as *mut _;
|
||||
unsafe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue