commit | c85d933ad4bd0ff44c59bd2e90b06ff54f8a7be4 | [log] [tgz] |
---|---|---|
author | Primiano Tucci <primiano@google.com> | Thu Nov 09 18:47:42 2017 +0000 |
committer | Primiano Tucci <primiano@google.com> | Thu Nov 09 18:47:42 2017 +0000 |
tree | 0ab2642fde6f4ae757c5091cdd34b138062be3cb | |
parent | 9ebb8826097d4aa2d44efd39f22a20ba0e19aa3a [diff] |
[IPC 3] Add Deferred class to handle async IPC responses. Deferred<T> is a wrapper for handling async results. The problem this is solving is the following: For each result argument of the methods generated from the .proto file: - The client wants to see something on which it can Bind() a callback, which is invoked asynchronously once reply is received from the host. - The host wants to expose something to embedder that implements the IPC methods to allow them to provide an asynchronous reply back to the client. Eventually even more than once, for the case streaming replies. In both cases we want to make sure that callbacks don't get lost along the way. To address this, this class will automatically reject the callbacks if they are not resolved at destructor time (or the object is std::move()'d). The client is supposed to use this class as follows: class GreeterProxy { void SayHello(const HelloRequest&, Deferred<HelloReply> reply) } ... Deferred<HelloReply> reply; reply.Bind([] (AsyncResult<HelloReply> reply) { std::cout << reply.success() ? reply->message : "failure"; }); host_proxy_instance.SayHello(req, std::move(reply)); The host instead is supposed to use this as follows: class GreeterImpl : public Greeter { void SayHello(const HelloRequest& req, Deferred<HelloReply> reply) { AsyncResult<HelloReply> reply = AsyncResult<HelloReply>::New(); reply->set_greeting("Hello " + req.name) reply.Resolve(std::move(reply)); } } Or for more complex cases, the deferred object can be std::move()'d outside and the reply can continue asynchrnously later. Bug: 68854111 Test: ipc_unittests --gtest_filter=DeferredTest.* Change-Id: Ibc2b11e92e3bb2d29db9f3509b0eeec556697ab0
This project is meant to be built both as part of the Android tree and from a standalone checkout
For internal docs see this page
Android is the platform targeted in the first milestones. Right now Linux desktop and OSX are maintained best-effort.
All dependent libraries are self-hosted and pulled by the build/install-build-deps
script.
The only requirements on the host are python, git and a compiler (preferably clang, gcc is maintained best-effort):$ sudo apt-get update && sudo apt-get install git clang python
Then:$ git clone https://android.googlesource.com/platform/external/perfetto.git
This project uses Android AOSP Gerrit for code reviews and uses the Google C++ style. Currently targets -std=c++11
.
You can use both git cl upload
from Chromium depot tools or Android repo to upload patches.
git cl
is quite convenient as it supports code auto-formatting via git cl format
.
See https://source.android.com/source/contributing for more details about external contributions and CLA signing.
If you are a chromium developer and have depot_tools installed you can avoid the build/
prefix below and just use gn/ninja from depot_tools.
$ build/install-build-deps
to install third-party build deps (NDK etc)
$ build/gn args out/android
to generate build files and enter in the editor:
target_os = "android" # Leave empty for local testing target_cpu = "arm" or "arm64" # Only when building for Android
(See the Build Configurations section below for more)
$ build/ninja -C out/android all
TODO. The plan is to autogenerate the Android.bp build files from the master GN build files (or temporarily maintain both until we can autogenerate them).
$ build/ninja -C out/default (tracing_unittests | tracing_benchmarks) $ out/default/tracing_unittests --gtest_help
Either connect a device in ADB mode or use the bundled emulator.
To start the emulator:$ build/run_android_emulator (arm | arm64) &
To run the tests (either on the emulator or physical device):$ build/run_android_test out/default tracing_unittests
The following GN args are supported:
target_os = "android" | "linux" | "mac"
:
Defaults to the current host, set "android" to build for Android.
target_cpu = "arm" | "arm64" | "x86" | "x64"
:
Defaults to "arm"
when target_os
== "android"
, "x64"
when targeting the host. 32-bit host builds are not supported.
is_debug = true | false
:
Toggles Debug (default) / Release mode.
is_clang = true | false
:
Use Clang (default) / GCC. It requires clang 3.5+ to be installed on the host. Clang is the default compiler on Mac (% having installed Xcode). On Linux: sudo apt-get update && sudo apt-get install clang
cc = "gcc" / cxx = "g++"
:
Uses a different compiler binary (default: autodetected depending on is_clang).
is_asan = true
:
Enables Address Sanitizer
is_lsan = true
:
Enables Leak Sanitizer
(Linux/Mac only)
is_msan = true
:
Enables Memory Sanitizer
(Linux only)
is_tsan = true
:
Enables Thread Sanitizer
(Linux/Mac only)
is_ubsan = true
:
Enables Undefined Behavior Sanitizer