Mojo Core Embedder API
This document is a subset of the Mojo documentation.
Overview
The Mojo Core Embedder API enables process to initialize and use Mojo for IPC, using an implementation of Mojo Core that is statically linked into the application. See the note about dynamic linking here for more information about an alternative approach to Mojo Core initialization.
NOTE: Unless you are introducing a new binary entry point into the system (e.g., a new executable with a new main()
definition), you probably don't need to know anything about the Embedder API. Most processes defined in the Chrome repo today already fully initialize Mojo Core so that all other public Mojo APIs just work out of the box.
Basic Initialization
As an embedder, initializing Mojo Core requires a single call to mojo::core::Init
:
#include "mojo/core/embedder/embedder.h" int main(int argc, char** argv) {
mojo::core::Init(); // Now you can create message pipes, write messages, etc return 0;
}
This enables local API calls to work, so message pipes etc can be created and used. In some cases (particuarly many unit testing scenarios) this is sufficient, but to support any actual multiprocess communication (e.g. sending or accepting Mojo invitations), a second IPC initialization step is required.
IPC Initialization
Internal Mojo IPC implementation requires a background TaskRunner
on which it can watch for inbound I/O from other processes. This is configured using a ScopedIPCSupport
object, which keeps IPC support alive through the extent of its lifetime.
Typically an application will create a dedicated background thread and give its TaskRunner
to Mojo. Note that in Chromium, we use the existing “IO thread” in the browser process and content child processes. In general, any thread used for Mojo IPC support must be running a base::MessageLoop::TYPE_IO
loop.
#include "base/threading/thread.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/embedder/scoped_ipc_support.h" int main(int argc, char** argv) {
mojo::core::Init(); base::Thread ipc_thread("ipc!");
ipc_thread.StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); // As long as this object is alive, all Mojo API surface relevant to IPC
// connections is usable, and message pipes which span a process boundary will
// continue to function.
mojo::core::ScopedIPCSupport ipc_support(
ipc_thread.task_runner(),
mojo::core::ScopedIPCSupport::ShutdownPolicy::CLEAN); return 0;
}
This process is now fully prepared to use Mojo IPC!
Note that all existing process types in Chromium already perform this setup very early during startup.
Connecting Two Processes
Once IPC is initialized, you can bootstrap connections to other processes by using the public Invitations API.
Mojo Core Embedder API的更多相关文章
- Mojo C++ System API
This document is a subset of the Mojo documentation. Contents Overview Scoped, Typed Handles Message ...
- 使用 Swagger 自动生成 ASP.NET Core Web API 的文档、在线帮助测试文档(ASP.NET Core Web API 自动生成文档)
对于开发人员来说,构建一个消费应用程序时去了解各种各样的 API 是一个巨大的挑战.在你的 Web API 项目中使用 Swagger 的 .NET Core 封装 Swashbuckle 可以帮助你 ...
- 在ASP.NET Core Web API上使用Swagger提供API文档
我在开发自己的博客系统(http://daxnet.me)时,给自己的RESTful服务增加了基于Swagger的API文档功能.当设置IISExpress的默认启动路由到Swagger的API文档页 ...
- Docker容器环境下ASP.NET Core Web API应用程序的调试
本文主要介绍通过Visual Studio 2015 Tools for Docker – Preview插件,在Docker容器环境下,对ASP.NET Core Web API应用程序进行调试.在 ...
- 在docker中运行ASP.NET Core Web API应用程序
本文是一篇指导快速演练的文章,将介绍在docker中运行一个ASP.NET Core Web API应用程序的基本步骤,在介绍的过程中,也会对docker的使用进行一些简单的描述.对于.NET Cor ...
- ASP.NET Core Web API Cassandra CRUD 操作
在本文中,我们将创建一个简单的 Web API 来实现对一个 “todo” 列表的 CRUD 操作,使用 Apache Cassandra 来存储数据,在这里不会创建 UI ,Web API 的测试将 ...
- 在Mac下创建ASP.NET Core Web API
在Mac下创建ASP.NET Core Web API 这系列文章是参考了.NET Core文档和源码,可能有人要问,直接看官方的英文文档不就可以了吗,为什么还要写这些文章呢? 原因如下: 官方文档涉 ...
- ASP.NET Core Web API 开发-RESTful API实现
ASP.NET Core Web API 开发-RESTful API实现 REST 介绍: 符合REST设计风格的Web API称为RESTful API. 具象状态传输(英文:Representa ...
- Core Web API上使用Swagger提供API文档
在ASP.NET Core Web API上使用Swagger提供API文档 我在开发自己的博客系统(http://daxnet.me)时,给自己的RESTful服务增加了基于Swagger的AP ...
随机推荐
- C++逐行读取文本文件的正确做法
作者:朱金灿 来源:http://blog.csdn.net/clever101 之前写了一个分析huson日志的控制台程序,其中涉及到C++逐行读取文本文件的做法,代码是这样写的: ifstream ...
- CoordinatorLayout:android之ScrollingActivity
1.效果图 2.新建SrcollingActivity后生成代码为: <?xml version="1.0" encoding="utf-8"?> ...
- addFooterView(v)与 addHeaderView(v)之后 头或者尾部没有加上去
myExpandableListView.addHeaderView(headView); myExpandableListView.addFooterView(footerView); 原因很简单: ...
- CSS大纲
- 基于LXC的虚拟网络自动部署
一.问题: 在搭建以LXC为基础的虚拟网络时,网络参数繁多,配置过程繁琐.面临一个新的网络拓扑结构时,通常要花费大量时间来构建网络.因此,如果能通过配置文件,自动生成相对应的网络拓扑,并生成操作指令. ...
- ubuntu12.04开启Framebuffer
一.framebuffer概述 Framebuffer在Linux中是作为设备来实现的,它是对图形硬件的一种抽象,代表着显卡中的帧缓冲区(Framebuffer).通过Framebuffer设备,上层 ...
- web前端项目规范
项目目录规范 . ├─ css ├─ component ├─ img ├─ js ├─ page ├─ test ├─ package.json ├─ README.md css 存放样式类文件,且 ...
- JavaScript和CSS实用工具、库与资源
JavaScript和CSS实用工具.库与资源 JavaScript 库 Particles.js - 一个用于在网页上创建漂亮的浮动粒子的 JS 库: Three.js - 用于在网页上创建 3 ...
- java JSON 和 Object 相互转换
1.导入 jackson jar <dependency> <groupId>com.fasterxml.jackson.core</groupId> <ar ...
- NoReferencedTableError: Foreign key associated with column ** with which to generate a foreign key to target column 'id'
1.使用 python flask 框架做项目时,在实体类中配置了 映射关系, message: id = db.Column(db.Integer, primary_key=True)message ...