KeyedService and KeyedServiceFactory together support building a dependency tree of services that are all keyed off the same object (typically, content::BrowserContext or web::BrowserState), and whose teardown order is managed according to the expressed dependency order.
KeyedService is a layered component (https://sites.google.com/a/chromium.org/dev/developers/design-documents/layered-components-design) to enable it to be shared cleanly on iOS.
This component has the following structure:
On Android, C++ keyed services often have a corresponding Java object. In such cases, the C++ part should own the Java one. You can find more details in docs/android_jni_ownership_best_practices.md.