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 ...
随机推荐
- gvim74 提示报错 “无法加载库python27.dll”
官方提供的gvim安装文件默认是支持python和python3两种模式的,编译时带有该选项,但并没有附带对应的运行库和运行环境.所以在本地没有安装python时直接在vim中执行 :py print ...
- windows 2008 中IIS7.0以上如何设置404错误页面
404错误页面的设置,不仅仅可以提高用户体验度,从SEO方面考虑,也是非常重要的.今天,笔者在这里介绍一下在windows 2008下如何设置404错误页面. 注意:设置404有我这里介绍2种方式,推 ...
- UNP学习笔记3——基本UDP套接字编程
1 概述 TCP和UDP网络编程存在一些本质的差异,主要是由于传输层的差别:UDP是无连接的不可靠的数据报协议,而TCP是面向连接的字节流协议. 下图是典型的UDP客户端和服务器之间的通信流程.客户不 ...
- C++小程序(1)——文件整理工具
网上下载的漫画是jpg或png之类的图片文件,用系统自带的图片管理器看不方便,想要能把图片想网页一样浏览的功能,找了很多图片管理器也没有带这个功能,于是就自己编写了一个小程序实现. 思想就是在图片目录 ...
- CDR 2017版本LiveSketch工具是什么,怎么用?
LiveSketch 工具在提供手绘草图的简便性和速度的同时,结合了智能笔触调整和向量绘图.在您绘制草图时,CorelDRAW 2017会分析您输入笔触的属性.时序和空间接近度,对其进行调整并将其转换 ...
- Mysql ERROR 1067: Invalid default value for 字段
问题: //今天把一个数据库的sql文件导入到另一个数据库出现以下异常: Mysql ERROR 1067: Invalid default value for 字段 //原因是因为之前导出数据里面有 ...
- Extjs获取input值的几种方法
记录一下: ExtJs获取文本框中值的几种方式 EXTHTML 1.Html文本框 如: 获取值的方式为: var tValue = Ext.getDom('test').value; 或者 var ...
- [TJOI2015]线性规划
题目:洛谷P3973.BZOJ3996. 题目大意:给你n,参数b[][]和c[](里面的数均>0),要你求一个数组A[](0/1,1表示选择),已知:1. 若同时选择X和Y,获得B[x][y] ...
- [luogu] P4364 [九省联考2018]IIIDX(贪心)
P4364 [九省联考2018]IIIDX 题目背景 Osu 听过没?那是Konano 最喜欢的一款音乐游戏,而他的梦想就是有一天自己也能做个独特酷炫的音乐游戏.现在,他在世界知名游戏公司KONMAI ...
- Js原生实现抽奖功能
<div>代码 按钮代码 JS原生代码 完整的代码: <div style="width:365px;height:300px;border:2px solid gree ...