An InvalidationHandler is a client (receiver) of Invalidations. Every feature that wants to receive Invalidations needs to implement an InvalidationHandler and register it with InvalidationService (see below). InvalidationHandler has the following methods (the list is not exhaustive):
InvalidationService is the main entry point for clients of the Invalidations system. This is where an InvalidationHandler registers/unregisters itself, and where it registers the Topics it is interested in. When a message arrives, InvalidationService calls OnIncomingInvalidation for the receiving InvalidationHandler.
InvalidationService provides the following methods (the list is not exhaustive):
An InvalidationService instance is usually tied to a profile (via ProfileInvalidationProviderFactory), but on ChromeOS there is also a device-scoped instance, managed by AffiliatedInvalidationServiceProvider (used for device policies, which must apply even before any user is signed in).
FCMInvalidationService is the only real (non-test) implementation of InvalidationService, using FCM+Fandango as its publish/subscribe service. It delegates most of the work to InvalidatorRegistrarWithMemory and FCMInvalidationListener.
InvalidatorRegistrarWithMemory maintains the mapping between Topics and InvalidationHandlers. When a message arrives via FCMInvalidationListener, InvalidatorRegistrarWithMemory dispatches that message (invalidation) to the appropriate InvalidationHandler.
InvalidatorRegistrarWithMemory also persists the set of Topics per handler, to avoid redundant re-subscriptions after every Chrome restart.
FCMInvalidationListener gets the list of interesting Topics from FCMInvalidationService. It passes the Topics to PerUserTopicSubscriptionManager (see below) for subscription/unsubscription, receives Invalidation messages from FCMNetworkHandler, and passes Invalidations for the interesting Topics back to FCMInvalidationService.
PerUserTopicSubscriptionManager manages subscriptions to Topics, sending subscription or unsubscriptions requests to the server as necessary. It persists the set of subscribed Topics in prefs to avoid redundant re-subscriptions after Chrome restarts.
FCMNetworkHandler is responsible for communication via GCM channel. It provides the following functionality: