Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /refs/heads/main /. /mojo /public /cpp /platform
tree: c12ea7c3088ad5696497aae5774b040e40f8a5cb [path history][tgz]
  1. tests/
  2. BUILD.gn
  3. DEPS
  4. named_platform_channel.cc
  5. named_platform_channel.h
  6. named_platform_channel_mac.cc
  7. named_platform_channel_posix.cc
  8. named_platform_channel_win.cc
  9. platform_channel.cc
  10. platform_channel.h
  11. platform_channel_endpoint.cc
  12. platform_channel_endpoint.h
  13. platform_channel_server.cc
  14. platform_channel_server.h
  15. platform_channel_server_endpoint.cc
  16. platform_channel_server_endpoint.h
  17. platform_channel_server_mac.cc
  18. platform_channel_server_posix.cc
  19. platform_channel_server_win.cc
  20. platform_handle.cc
  21. platform_handle.h
  22. platform_handle_internal.h
  23. platform_handle_security_util_win.cc
  24. platform_handle_security_util_win.h
  25. README.md
  26. socket_utils_posix.cc
  27. socket_utils_posix.h
mojo/public/cpp/platform/README.md

Mojo C++ Platform API

This document is a subset of theMojo documentation.

Overview

The Mojo C++ Platform API provides a lightweight set of abstractions around stable platform primitive APIs like UNIX domain sockets and Windows named pipes. This API is primarily useful in conjunction with MojoInvitations to bootstrap Mojo IPC between two processes.

Platform Handles

ThePlatformHandle type provides a move-only wrapper around an owned, platform-specific primitive handle types. The type of primitive it holds can be any of the following:

  • Windows HANDLE (Windows only)
  • Fuchsia zx_handle_t (Fuchsia only)
  • Mach send right (OSX only)
  • POSIX file descriptor (POSIX systems only)

See theheader for more details.

Platform Channels

ThePlatformChannel type abstracts a platform-specific IPC FIFO primitive primarily for use with the MojoInvitations API. Constructing aPlatformChannel instance creates the underlying system primitive with two transferrablePlatformHandle instances, each thinly wrapped as aPlatformChannelEndpoint for additional type-safety. One endpoint is designated aslocal and the otherremote, the intention being that the remote endpoint will be transferred to another process in the system.

See theheader for more details. See theInvitations documentation for an example of usingPlatformChannel with an invitation to bootstrap IPC between a process and one of its newly launched child processes.

Named Platform Channels

For cases where it is not feasible to transfer aPlatformHandle from one running process to another, the Platform API also providesNamedPlatformChannel, which abstracts a named system resource that can facilitate communication similarly toPlatformChannel.

ANamedPlatformChannel upon construction will begin listening on a platform-specific primitive (a named pipe server on Windows, a domain socket server on POSIX,etc.). The globally reachable name of the server (e.g. the socket path) can be specified at construction time viaNamedPlatformChannel::Options::server_name, but if no name is given, a suitably random one is generated and used.

// In one processmojo::NamedPlatformChannel::Options options;mojo::NamedPlatformChannel named_channel(options);OutgoingInvitation::Send(std::move(invitation),                         named_channel.TakeServerEndpoint());SendServerNameToRemoteProcessSomehow(named_channel.GetServerName());// In the other processvoidOnGotServerName(const mojo::NamedPlatformChannel::ServerName& name){// Connect to the server.  mojo::PlatformChannelEndpoint endpoint=      mojo::NamedPlatformChannel::ConnectToServer(name);// Proceed normally with invitation acceptance.auto invitation= mojo::IncomingInvitation::Accept(std::move(endpoint));// ...}

[8]ページ先頭

©2009-2025 Movatter.jp