1*6dbdd20aSAndroid Build Coastguard WorkerHow to use this library 2*6dbdd20aSAndroid Build Coastguard Worker----------------------- 3*6dbdd20aSAndroid Build Coastguard WorkerThere are three options to use this library: 4*6dbdd20aSAndroid Build Coastguard Worker 5*6dbdd20aSAndroid Build Coastguard Worker## Option 1) Fully in-process 6*6dbdd20aSAndroid Build Coastguard WorkerIn this mode Producer, Consumers and the Service are hosted in the same process. 7*6dbdd20aSAndroid Build Coastguard WorkerThis is not too interesting other than tests and particular cases of nesting 8*6dbdd20aSAndroid Build Coastguard Workertracing instances coming from different libraries within the same process 9*6dbdd20aSAndroid Build Coastguard Worker(concrete example v8, skia and webrtc in Chrome). 10*6dbdd20aSAndroid Build Coastguard WorkerIn this configuration, the client is expected to at least: 11*6dbdd20aSAndroid Build Coastguard Worker- Create a TracingService instance via TracingService::CreateInstance 12*6dbdd20aSAndroid Build Coastguard Worker (see `core/tracing_service.h`) 13*6dbdd20aSAndroid Build Coastguard Worker- Subclass Producer (`core/producer.h`) and connect it to the service. 14*6dbdd20aSAndroid Build Coastguard Worker- Provide a TaskRunner implementation (see `test/test_task_runner.h`) 15*6dbdd20aSAndroid Build Coastguard Worker- Provide a trivial SharedMemory implementation (`core/shared_memory.h`) which 16*6dbdd20aSAndroid Build Coastguard Worker is simply backed by a malloc() buffer. 17*6dbdd20aSAndroid Build Coastguard Worker 18*6dbdd20aSAndroid Build Coastguard Worker## Option 2) Using the provided UNIX RPC transport 19*6dbdd20aSAndroid Build Coastguard WorkerThe `include/unix_rpc` provides the building blocks necessary to implement a RPC 20*6dbdd20aSAndroid Build Coastguard Workermechanism that allows Producer(s), Consumer(s) and Service to be hosted on 21*6dbdd20aSAndroid Build Coastguard Workerdifferent processes on the same machine and talk over a UNIX domain socket. 22*6dbdd20aSAndroid Build Coastguard Worker- Producer(s) are expected to get a service proxy via 23*6dbdd20aSAndroid Build Coastguard Worker`UnixServiceConnection::ConnectAsProducer()`. 24*6dbdd20aSAndroid Build Coastguard Worker- The `Service` must be instantiated via `UnixServiceHost::CreateInstance()`. The 25*6dbdd20aSAndroid Build Coastguard Workerreturned instance encapsulates the `Service` and exposes two UNIX sockets (one 26*6dbdd20aSAndroid Build Coastguard Workerfor Producer(s), one for Consumer(s)) on the current process. 27*6dbdd20aSAndroid Build Coastguard Worker 28*6dbdd20aSAndroid Build Coastguard Worker## Option 3) Providing a custom RPC transport 29*6dbdd20aSAndroid Build Coastguard WorkerSimilar to Option 2, but the client creates its own transport mechanism, 30*6dbdd20aSAndroid Build Coastguard Workerdefining how methods are proxies between instances and providing a SharedMemory 31*6dbdd20aSAndroid Build Coastguard Workerimplementation that can be transferred through RPC. Concrete example of this is 32*6dbdd20aSAndroid Build Coastguard WorkerChrome implementing this library over a Mojo transport. 33*6dbdd20aSAndroid Build Coastguard Worker 34*6dbdd20aSAndroid Build Coastguard Worker 35*6dbdd20aSAndroid Build Coastguard WorkerDirectory layout 36*6dbdd20aSAndroid Build Coastguard Worker---------------- 37*6dbdd20aSAndroid Build Coastguard Worker 38*6dbdd20aSAndroid Build Coastguard Worker`include/` 39*6dbdd20aSAndroid Build Coastguard WorkerIs the public API that clients of this library are allowed to depend on. 40*6dbdd20aSAndroid Build Coastguard WorkerHeaders inside include/ cannot depend on anything else. 41*6dbdd20aSAndroid Build Coastguard Worker 42*6dbdd20aSAndroid Build Coastguard Worker`src/` 43*6dbdd20aSAndroid Build Coastguard WorkerIs the actual implementation that clients can link but not expected to access 44*6dbdd20aSAndroid Build Coastguard Workerat a source-code level. 45*6dbdd20aSAndroid Build Coastguard Worker 46*6dbdd20aSAndroid Build Coastguard Worker 47*6dbdd20aSAndroid Build Coastguard Worker**Both have the following sub-structure**: 48*6dbdd20aSAndroid Build Coastguard Worker 49*6dbdd20aSAndroid Build Coastguard Worker`{include,src}/core/` 50*6dbdd20aSAndroid Build Coastguard Worker"Core" is the pure c++17 tracing machinery that deals with bookkeeping, 51*6dbdd20aSAndroid Build Coastguard Workerring-buffering, partitioning and multiplexing but knows nothing about 52*6dbdd20aSAndroid Build Coastguard Workerplatform-specific things like implementation of shared memory and RPC mechanism. 53*6dbdd20aSAndroid Build Coastguard Worker 54*6dbdd20aSAndroid Build Coastguard Worker`{include,src}/unix_rpc/` 55*6dbdd20aSAndroid Build Coastguard WorkerA concrete implementation of the transport layer based on UNIX domain sockets 56*6dbdd20aSAndroid Build Coastguard Workerand posix shared memory. 57