mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Make service workers talk to their serviceworkerglobalscopes
This commit is contained in:
parent
72279cc7eb
commit
0996b38ade
13 changed files with 184 additions and 46 deletions
|
@ -12,6 +12,7 @@ use js::jsapi::{JSContext, JS_ReadStructuredClone, JS_STRUCTURED_CLONE_VERSION};
|
|||
use js::jsapi::{JS_ClearPendingException, JS_WriteStructuredClone};
|
||||
use libc::size_t;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
/// A buffer for a structured clone.
|
||||
pub struct StructuredCloneData {
|
||||
|
@ -45,6 +46,21 @@ impl StructuredCloneData {
|
|||
})
|
||||
}
|
||||
|
||||
/// Converts a StructuredCloneData to Vec<u64>
|
||||
pub fn move_to_arraybuffer(self) -> Vec<u64> {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self.data, self.nbytes).to_vec()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts back to StructuredCloneData using a pointer and no of bytes
|
||||
pub fn make_structured_clone(data: *mut u64, nbytes: size_t) -> StructuredCloneData {
|
||||
StructuredCloneData {
|
||||
data: data,
|
||||
nbytes: nbytes
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads a structured clone.
|
||||
///
|
||||
/// Panics if `JS_ReadStructuredClone` fails.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue