New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement MessagePort and MessageChannel #16622
Closed
+794
−87
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9edd4ec
Add PortMessageQueue
KiChjang 74bcb9d
Accept transfer argument for StructuredCloneData::write
KiChjang ea481b7
Allow structured clone reads to return a boolean
KiChjang 055bdd1
Add Transferable trait
KiChjang 5ddcdb5
Add basic skeletons to MessagePort
KiChjang e99eb47
Implement transfer and transfer-receiving steps on MessagePort
KiChjang f023385
Use transfer and transfer_receive in StructuredClone callbacks
KiChjang 99842e4
Implement MessageChannel
KiChjang c20ed6a
Freeze the array object for the MessageEvent ports attribute
KiChjang e4d075b
Implement transfer argument on window.postMessage
KiChjang 25fa53a
Use ReentrantMutex instead for MessagePortInternal
KiChjang 4da8a00
Accept origin as a parameter in dispatch_jsval
KiChjang 5bc41b5
Fix BorrowMut crash with pending_port_message
KiChjang 498fbef
Detach port on closure and check for detached during transfer
KiChjang 5693b81
Enable webmessaging tests
KiChjang File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
| @@ -0,0 +1,29 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| //! Trait representing the concept of [transferable objects] | ||
| //! (https://html.spec.whatwg.org/multipage/#transferable-objects). | ||
| use crate::dom::bindings::reflector::DomObject; | ||
| use js::jsapi::{JSContext, JSStructuredCloneReader, MutableHandleObject}; | ||
| use std::os::raw; | ||
|
|
||
| pub trait Transferable : DomObject { | ||
| fn transfer( | ||
| &self, | ||
| closure: *mut raw::c_void, | ||
| content: *mut *mut raw::c_void, | ||
| extra_data: *mut u64, | ||
| ) -> bool; | ||
| fn transfer_receive( | ||
| cx: *mut JSContext, | ||
| r: *mut JSStructuredCloneReader, | ||
| closure: *mut raw::c_void, | ||
| content: *mut raw::c_void, | ||
| extra_data: u64, | ||
| return_object: MutableHandleObject, | ||
| ) -> bool; | ||
| fn detached(&self) -> Option<bool> { None } | ||
| fn set_detached(&self, _value: bool) { } | ||
| fn transferable(&self) -> bool { false } | ||
| } |
| @@ -154,7 +154,8 @@ impl DissimilarOriginWindowMethods for DissimilarOriginWindow { | ||
|
|
||
| // Step 1-2, 6-8. | ||
| // TODO(#12717): Should implement the `transfer` argument. | ||
| let data = StructuredCloneData::write(cx, message)?; | ||
| rooted!(in(cx) let transfer = UndefinedValue()); | ||
| let data = StructuredCloneData::write(cx, message, transfer.handle())?; | ||
KiChjang
Author
Member
|
||
|
|
||
| // Step 9. | ||
| self.post_message(origin, data); | ||
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
could the TODO on line 160 now be removed?