Fix lifetime of PrefetchGCMAppHandler |
|||
Issue descriptionGCMAppHandlers must be installed at the time of GCMDriver construction so that any incoming messages will be properly routed. All clients today add their app handlers at some point *close* to profile initialization, but the lifetime relative to GCM driver is not obviously guaranteed. Prefetch attempts to be explicit by using DependsOn for lifetime control. By making GCMProfileService depend on PrefetchService, we guarantee the following: * Prefetch does not affect the creation moment of GCM profile service * The Prefetch app handler will be installed exactly at creation time of the GCM driver. This has a few downsides, however: * It /feels/ strange to many people that GCM would depend on the app handler. * The pattern is unique among app handlers in Chrome * The PrefetchService cannot DependsOn the InstanceID system as that would be a circular dependency. Instead, it must use GetForProfile on demand, which necessitates extra proxy code to work in //components. This tracks unifying the consumers of GCM.
,
Jun 7 2017
,
Jun 7 2017
I think we should delay start the core of GCMDriver. Different features could call GCMDriver::AddAppHandler to register a handler at browser startup time. The core of GCMDriver will not start at that time. Only some seconds after the browser finishes the startup, the core of GCMDriver will start to run and the GCM messages get received and dispatched. For Android, we need to figure out a way to delay start ChromeGcmListenerService. Perhaps we can use AlarmManager to send a pending intent to start this service.
,
Jun 7 2017
I think the best one is the "Another solution" from comment #1. Here indeed we have a two-way 'dependency': 1. Prefetch [sometimes] needs to call methods from GCM 2. GCM needs to call Prefetch if it has a hot message to pass to Prefetch's AppHandler. The mentioned solution splits this the right way: GCM might not depend on Prefetch as a service, but it has to at least collect AppHandlers which can be simple listeners. AppHandlers may fetch/create their respective services if and when they receive the actual message from GCMDriver. I think this will allow to not use any calls to DependsOn as they become simply unnecessary.
,
Jun 7 2017
WRT #3: I am not sure we can delay-start GCMDriver, because if the actual GCM message was received by core GCM code in GMS, it'll invoke Chrome on intent with that message and we must process that intent, is this correct?
,
Jun 7 2017
For #5, we can choose not to add the intent to Android manifest. Instead, we can use AlarmManager to setup the intent at a later time. This is what I found from search. The Android expert please comments on the feasibility of this approach.
,
Jun 14 2017
|
|||
►
Sign in to add a comment |
|||
Comment 1 by dewittj@chromium.org
, Jun 5 2017