Skip to content

Commit

Permalink
LibWeb: Port to Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
stasoid committed Dec 21, 2024
1 parent 0d6f9fb commit ca51378
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
30 changes: 12 additions & 18 deletions Libraries/LibWeb/HTML/MessagePort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,11 @@ WebIDL::ExceptionOr<void> MessagePort::transfer_steps(HTML::TransferDataHolder&
m_remote_port->m_has_been_shipped = true;

// 2. Set dataHolder.[[RemotePort]] to remotePort.
if constexpr (IsSame<IPC::Transport, IPC::TransportSocket>) {
auto fd = MUST(m_transport->release_underlying_transport_for_transfer());
m_transport = {};
data_holder.fds.append(IPC::File::adopt_fd(fd));
data_holder.data.append(IPC_FILE_TAG);
} else {
VERIFY(false && "Don't know how to transfer IPC::Transport type");
}
// TODO: Mach IPC
auto fd = MUST(m_transport->release_underlying_transport_for_transfer());
m_transport = {};
data_holder.fds.append(IPC::File::adopt_fd(fd));
data_holder.data.append(IPC_FILE_TAG);
}

// 4. Otherwise, set dataHolder.[[RemotePort]] to null.
Expand All @@ -128,16 +125,13 @@ WebIDL::ExceptionOr<void> MessagePort::transfer_receiving_steps(HTML::TransferDa
// (This will disentangle dataHolder.[[RemotePort]] from the original port that was transferred.)
auto fd_tag = data_holder.data.take_first();
if (fd_tag == IPC_FILE_TAG) {
if constexpr (IsSame<IPC::Transport, IPC::TransportSocket>) {
auto fd = data_holder.fds.take_first();
m_transport = IPC::Transport(MUST(Core::LocalSocket::adopt_fd(fd.take_fd())));

m_transport->set_up_read_hook([strong_this = GC::make_root(this)]() {
strong_this->read_from_transport();
});
} else {
VERIFY(false && "Don't know how to receive IPC::Transport type");
}
// TODO: Mach IPC
auto fd = data_holder.fds.take_first();
m_transport = IPC::Transport(MUST(Core::LocalSocket::adopt_fd(fd.take_fd())));

m_transport->set_up_read_hook([strong_this = GC::make_root(this)]() {
strong_this->read_from_transport();
});
} else if (fd_tag != 0) {
dbgln("Unexpected byte {:x} in MessagePort transfer data", fd_tag);
VERIFY_NOT_REACHED();
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibWeb/HTML/WorkerAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void WorkerAgent::initialize(JS::Realm& realm)

auto worker_socket = MUST(Core::LocalSocket::adopt_fd(worker_socket_file.take_fd()));
MUST(worker_socket->set_blocking(true));
static_assert(IsSame<IPC::Transport, IPC::TransportSocket>, "Handle other IPC::Transport types here");

// TODO: Mach IPC
auto transport = IPC::Transport(move(worker_socket));

m_worker_ipc = make_ref_counted<WebWorkerClient>(move(transport));
Expand Down

0 comments on commit ca51378

Please sign in to comment.