mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibWeb+WebWorker: Convert Workers to use MessagePorts for postMessage
This aligns Workers and Window and MessagePorts to all use the same mechanism for transferring serialized messages across realms. It also allows transferring more message ports into a worker. Re-enable the Worker-echo test, as none of the MessagePort tests have themselves been flaky, and those are now using the same underlying implementation.
This commit is contained in:
parent
37f2d49818
commit
b10fee00eb
21 changed files with 159 additions and 222 deletions
|
@ -73,7 +73,7 @@ public:
|
|||
ENUMERATE_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(__ENUMERATE)
|
||||
#undef __ENUMERATE
|
||||
|
||||
WebIDL::ExceptionOr<void> post_message(JS::Value message, JS::Value transfer);
|
||||
WebIDL::ExceptionOr<void> post_message(JS::Value message, StructuredSerializeOptions const&);
|
||||
|
||||
// Non-IDL public methods
|
||||
|
||||
|
@ -84,14 +84,14 @@ public:
|
|||
// this is not problematic as it cannot be observed from script.
|
||||
void set_location(JS::NonnullGCPtr<WorkerLocation> loc) { m_location = move(loc); }
|
||||
|
||||
void set_outside_port(NonnullOwnPtr<Core::BufferedLocalSocket> port);
|
||||
void set_internal_port(JS::NonnullGCPtr<MessagePort> port);
|
||||
|
||||
void initialize_web_interfaces(Badge<WorkerEnvironmentSettingsObject>);
|
||||
|
||||
Web::Page* page() { return &m_page; }
|
||||
Web::Page* page() { return m_page.ptr(); }
|
||||
|
||||
protected:
|
||||
explicit WorkerGlobalScope(JS::Realm&, Web::Page&);
|
||||
explicit WorkerGlobalScope(JS::Realm&, JS::NonnullGCPtr<Web::Page>);
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
@ -99,13 +99,8 @@ private:
|
|||
JS::GCPtr<WorkerLocation> m_location;
|
||||
JS::GCPtr<WorkerNavigator> m_navigator;
|
||||
|
||||
OwnPtr<Core::BufferedLocalSocket> m_outside_port;
|
||||
enum class PortState : u8 {
|
||||
Header,
|
||||
Data,
|
||||
Error,
|
||||
} m_outside_port_state { PortState::Header };
|
||||
size_t m_outside_port_incoming_message_size { 0 };
|
||||
JS::NonnullGCPtr<Web::Page> m_page;
|
||||
JS::GCPtr<MessagePort> m_internal_port;
|
||||
|
||||
// FIXME: Add all these internal slots
|
||||
|
||||
|
@ -138,8 +133,6 @@ private:
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-cross-origin-isolated-capability
|
||||
bool m_cross_origin_isolated_capability { false };
|
||||
|
||||
Web::Page& m_page;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue