There's currently 12 out of 47 (~25%) subclasses of offline_pages::Task that do use the current time in their code. As these are all short lived tasks I feel like adding a clock pointer to task instances is not too much of a problem?
I'm about to land a CL that creates the abstraction (outside of the base Task class) and changes all Prefetching tasks to use it.
PrefetchDownloaderQuota should also be updated to not require a Clock instance anymore on creation and use the new abstraction instead.
I sadly landed the CL in #5 with an outdated commit description. It should have been:
> Consolidate Prefetching tasks time sources to using base::Clock
>
> This change adds a shared base::Clock pointer accessible via a static
> function, making it widely accessible (instead of limiting it to
> offline_pages::Task instances). The pointer can be overridden by tests.
>
> It also updates all time related calls in Task subclasses and their
> tests in:
>
> components/offline_pages/core/prefetch/tasks/
Uses of testing-only parameters have been replaced with instances of |OfflineClock|.
There are currently multiple calls to OfflineClock()->Now() within the offline_pages domain, however there is a new function, OfflineTimeNow(), which is a shortcut for OfflineClock()->Now() and will also allow us to remove the clock.h include from the files which OfflineClock is used in. Future work is needed to replace these calls with the new function.
Will be moving onto new work, so I will leave this issue incomplete and available.
Comment 1 by carlosk@chromium.org, Nov 20