Tweaks to the precache triggering code.

This commit encompasses a few related changes:

1. Enforce that IsPrecachingAllowed is called before IsPrecachingEnabled. This
is so that users are only selected into the field trial if it would have an
effect on them. Calling IsPrecachingEnabled triggers the field trial group
selection, and doing so for users for whom !IsPrecachingAllowed means that our
Enabled population consists of many users for whom precaching won't ultimately
run.

2. Renamed the externally facing methods to ShouldRun and WouldRun, so I could
lean on the compiler to ensure that I addressed all clients, and because
PrecacheManager and PrecacheLauncher were exposing two different notions of
"enabled", which I found confusing.

3. Make updatePrecachingEnabled wait, asynchronously, for the sync backend to
be initialized, before determining what value to pass to setIsPrecachingEnabled.
Previously, DeferredStartupHandler would call
PrecacheLauncher.updatePrecachingEnabled before the sync backend was enabled,
so the is_precaching_enabled pref would be set to false until either
PrivacyPreferences or ConnectionChangeReceiver called updatePrecachingEnabled.
This change should increase the likelihood that precaching will run when the
conditions are right, and decrease the time until that happens.

4. Get rid of the redundant PrivacyPreferencesManager parameter, to simplify
the interface and thus make the implementation more flexible.

5. Change from android.util.Log to org.chromium.base.Log, per presubmit
warning.

BUG=309216

Review URL: https://codereview.chromium.org/1266243003

Cr-Commit-Position: refs/heads/master@{#342427}


CrOS-Libchrome-Original-Commit: b2175430067b9063923edab0ac3ae1b986d11d39
1 file changed
tree: 3cd76f78b1e482274970ab74c2f7ad77c6fca17d
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/