• Home
  • Raw
  • Download

Lines Matching full:mojo

1 # Mojo C++ Bindings API
2 This document is a subset of the [Mojo documentation](/mojo/README.md).
7 The Mojo C++ Bindings API leverages the
8 [C++ System API](/mojo/public/cpp/system/README.md) to provide a more natural
9 set of primitives for communicating over Mojo message pipes. Combined with
11 [Mojom IDL and bindings generator](/mojo/public/tools/bindings/README.md), users
17 [//mojo/public/cpp/bindings](https://cs.chromium.org/chromium/src/mojo/public/cpp/bindings/README.m…
45 import("//mojo/public/tools/bindings/mojom.gni")
129 using LoggerPtr = mojo::InterfacePtr<Logger>;
130 using LoggerRequest = mojo::InterfaceRequest<Logger>;
144 In the world of Mojo bindings libraries these are effectively strongly-typed
168 mojo::MessagePipe pipe;
175 way to accomplish the same thing. [interface_request.h](https://cs.chromium.org/chromium/src/mojo/p…
180 auto request = mojo::MakeRequest(&logger);
187 type, which is a generated alias for `mojo::InterfacePtrInfo<Logger>`. This is
225 named `mojo::Binding<T>`. A `mojo::Binding<T>` bridges an implementation of `T`
226 with a single bound message pipe endpoint (via a `mojo::InterfaceRequest<T>`),
232 interface. Notice that the implementation itself owns a `mojo::Binding`. This is
233 a common pattern, since a bound implementation must outlive any `mojo::Binding`
256 mojo::Binding<sample::mojom::Logger> binding_;
288 object which binds it (*i.e.* the `mojo::Binding` in the above example) remains
353 mojo::Binding<sample::mojom::Logger> binding_;
386 * Mojo system-level causes: process terminated, resource exhausted, etc.
390 `mojo::InterfacePtr<T>` and it is destroyed.
400 All message pipe-binding C++ objects (*e.g.*, `mojo::Binding<T>`,
401 `mojo::InterfacePtr<T>`, *etc.*) support setting their connection error handler
409 LoggerImpl impl(mojo::MakeRequest(&logger));
440 Once a `mojo::InterfacePtr<T>` is destroyed, it is guaranteed that pending
444 Once a `mojo::Binding<T>` is destroyed, it is guaranteed that no more method
449 A common situation when calling mojo interface methods that take a callback is
459 …[**`mojo::WrapCallbackWithDropHandler`**](https://cs.chromium.org/chromium/src/mojo/public/cpp/bin…
461 …[**`mojo::WrapCallbackWithDefaultInvokeIfNotRun`**](https://cs.chromium.org/chromium/src/mojo/publ…
492 FROM_HERE, base::BindOnce(&GoBindALogger, mojo::MakeRequest(&logger)));
506 [Mojom enums](/mojo/public/tools/bindings/README.md#Enumeration-Types) translate
509 C++. Mojo also always defines a special enumerator `kMaxValue` that shares the
510 value of the highest enumerator: this makes it easy to record Mojo enums in
544 [Mojom structs](mojo/public/tools/bindings/README.md#Structs) can be used to
570 using EmployeePtr = mojo::StructPtr<Employee>;
599 a `struct` type is wrapped by the move-only `mojo::StructPtr` helper, which is
605 `mojo::StructPtr<T>` wrapping a new instance of the class constructed by
611 e1->username = "mojo";
618 auto e1 = mojom::Employee::New(42, "mojo", mojom::Department::kEngineering);
645 Employee::New(42, "mojo", mojom::Department::kEngineering));
648 auto e = Employee::New(42, "mojo", mojom::Department::kEngineering);
655 representative C++ class which is typically wrapped in a `mojo::StructPtr<T>`.
722 bread and butter of Mojo IPC is the ability to transfer interface endpoints
742 [Mojom IDL documentation](/mojo/public/tools/bindings/README.md#Primitive-Types),
758 using TablePtr = mojo::InterfacePtr<Table>;
759 using TableRequest = mojo::InterfaceRequest<Table>;
768 using DatabasePtr = mojo::InterfacePtr<Database>;
769 using DatabaseRequest = mojo::InterfaceRequest<Database>;
793 mojo::Binding<db::mojom::Table> binding_;
809 mojo::Binding<db::mojom::Database> binding_;
816 `mojo::InterfaceRequest<db::mojom::Table>`, which we know is just a
824 DatabaseImpl db_impl(mojo::MakeRequest(&database));
827 database->AddTable(mojo::MakeRequest(&table1));
828 database->AddTable(mojo::MakeRequest(&table2));
863 TableListenerImpl impl(mojo::MakeRequest(&listener));
880 [**`MakeStrongBinding`**](https://cs.chromium.org/chromium/src/mojo/public/cpp/bindings/strong_bind…
900 mojo::MakeStrongBinding(std::make_unique<LoggerImpl>(),
901 mojo::MakeRequest(&logger));
912 clients. [**`BindingSet`**](https://cs.chromium.org/chromium/src/mojo/public/cpp/bindings/binding_s…
949 mojo::Binding<system::mojom::LoggerProvider> provider_binding_;
950 mojo::BindingSet<system::mojom::Logger> logger_bindings_;
960 [**`InterfacePtrSet`**](https://cs.chromium.org/chromium/src/mojo/public/cpp/bindings/interface_ptr…
997 mojo::InterfacePtrSet<db::mojom::Table> listeners_;
1043 `mojo::AssociatedInterfacePtrInfo<Bar>`); associated interface request to
1045 `mojo::AssociatedInterfaceRequest<Bar>`).
1173 associating it, you can use `mojo::MakeIsolatedRequest()`. This will create
1179 * [Design: Mojo Associated Interfaces](https://docs.google.com/document/d/1nq3J_HbS-gvVfIoEhcVyxm1u…
1183 See [this document](https://www.chromium.org/developers/design-documents/mojo/synchronous-calls)
1241 [chromium_bindings_configuration.gni](https://cs.chromium.org/chromium/src/mojo/public/tools/bindin…
1243 [blink_bindings_configuration.gni](https://cs.chromium.org/chromium/src/mojo/public/tools/bindings/…
1254 [`mojo::StructTraits`](https://cs.chromium.org/chromium/src/mojo/public/cpp/bindings/struct_traits.…
1278 `//ui/gfx/geometry/mojo/geometry_struct_traits.h`:
1281 #include "mojo/public/cpp/bindings/struct_traits.h"
1283 #include "ui/gfx/geometry/mojo/geometry.mojom.h"
1285 namespace mojo {
1298 } // namespace mojo
1301 And in `//ui/gfx/geometry/mojo/geometry_struct_traits.cc`:
1304 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
1306 namespace mojo {
1320 } // namespace mojo
1340 mojom = "//ui/gfx/geometry/mojo/geometry.mojom"
1342 traits_headers = [ "//ui/gfx/geometry/mojo/geometry_struct_traits.h" ]
1344 "//ui/gfx/geometry/mojo/geometry_struct_traits.cc",
1345 "//ui/gfx/geometry/mojo/geometry_struct_traits.h",
1401 "//ui/gfx/geometry/mojo/geometry.typemap",
1407 [chromium_bindings_configuration.gni](https://cs.chromium.org/chromium/src/mojo/public/tools/bindin…
1437 | `handle` | `mojo::ScopedHandle`
1438 | `handle<message_pipe>` | `mojo::ScopedMessagePipeHandle`
1439 | `handle<data_pipe_consumer>` | `mojo::ScopedDataPipeConsumerHandle`
1440 | `handle<data_pipe_producer>` | `mojo::ScopedDataPipeProducerHandle`
1441 | `handle<shared_buffer>` | `mojo::ScopedSharedBufferHandle`
1446 | `string` | Value or reference to any type `T` that has a `mojo::StringTraits`…
1447 …ce to any type `T` that has a `mojo::ArrayTraits` specialization defined. By default this includes…
1448 …ence to any type `T` that has a `mojo::MapTraits` specialization defined. By default this includes…
1518 namespace mojo {
1538 } // namespace mojo
1581 [blink_bindings_configuration.gni](https://cs.chromium.org/chromium/src/mojo/public/tools/bindings/…
1602 import("mojo/public/tools/bindings/mojom.gni")
1617 [Versioning](/mojo/public/tools/bindings/README.md#Versiwoning).
1666 ### Using Mojo Bindings in Chrome
1668 See [Converting Legacy Chrome IPC To Mojo](/ipc/README.md).
1672 [Calling Mojo From Blink](https://www.chromium.org/developers/design-documents/mojo/calling-mojo-fr…