[Android TRM] Tweak SyncDerivedSuggestionEntrySource for V2 Local Tabs suggestions.
SyncDerivedSuggestionEntrySource (Source) implements common code to get suggestions from ForeignSessionHelper (V1) and Fetch and Rank service (V2), handling the need to request data refresh and awaiting update delay while also triggering update on sync or sign-in status changes. Fetch and Rank service recently started to serve Local Tab suggestions. This causes some mismatch for Source: * canUseData(): Previously this returns true if and only if user is signed in and has enabled sync (Sync Everything). With Local Tabs, canUseData() should always return true. * Caching: This was useful for establishing "fast path" to get data quickly and avoid churn (while "slow path" is potentially in flight). Local Tab data can change quickly and is easy to retrieve, so now "fast path" needs to take this into account. This CL implements a simple solution to the above: Add new field |mServesLocalTabs| passed via CTOR. * For ForeignSessionHelper this is false. * For Fetch and Rank service this is true. In Source this causes canUseData() to true, while also disabling caching. This is important for V2 model training, since for this we need to get distinct suggestion TrainingIds on each read for RecordAction(). Additional changes: * SuggestionBackend: Rename readCached() to read(). Propagate the name change, and update comments re. "cached". * TabResumptionModuleEnablement.SyncDerived: * Add isV2Enabled() and isV2EnabledWithLocalTabs(). * Fix shouldMakeProvider() to account for the case where sign-in / sync is disabled, but V2 Local Tab suggestions still possible. Tests: * SyncDerivedSuggestionEntrySourceTest: Add 2 tests to contrast the effects of passing false or true to |mServesLocalTabs|. Bug: 344949868, 343209609 Change-Id: Ia90413dab9a8d7e6e74622469815c27c12c9b798 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5598571 Commit-Queue: Samuel Huang <huangs@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by:Xi Han <hanxi@chromium.org> Cr-Commit-Position: refs/heads/main@{#1311059}
Loading
Please register or sign in to comment