| Index: components/offline_pages/core/prefetch/prefetch_service.h
|
| diff --git a/components/offline_pages/core/prefetch/prefetch_service.h b/components/offline_pages/core/prefetch/prefetch_service.h
|
| index 0bb85086e858397bff3ef9d02bcca313993ce0ea..057d9f03a9cb764d8a215a249df8d76af9d06949 100644
|
| --- a/components/offline_pages/core/prefetch/prefetch_service.h
|
| +++ b/components/offline_pages/core/prefetch/prefetch_service.h
|
| @@ -27,6 +27,19 @@ class PrefetchService : public KeyedService {
|
| GURL url;
|
| };
|
|
|
| + // A |ScopedBackgroundTask| is created when we are running in a background
|
| + // task. Destroying this object should notify the system that we are done
|
| + // processing the background task.
|
| + class ScopedBackgroundTask {
|
| + public:
|
| + ScopedBackgroundTask() = default;
|
| + virtual ~ScopedBackgroundTask() = default;
|
| +
|
| + // Used on destruction to inform the system about whether rescheduling is
|
| + // required.
|
| + virtual void SetNeedsReschedule(bool reschedule) = 0;
|
| + };
|
| +
|
| ~PrefetchService() override = default;
|
|
|
| // Called when a consumer has candidate URLs for the system to prefetch.
|
| @@ -43,6 +56,17 @@ class PrefetchService : public KeyedService {
|
| // Called to invalidate a single PrefetchURL entry identified by |client_id|.
|
| // If multiple have the same |client_id|, they will all be removed.
|
| virtual void RemovePrefetchURLsByClientId(const ClientId& client_id) = 0;
|
| +
|
| + // Called when Android OS has scheduled us for background work. When
|
| + // destroyed, |task| will call back and inform the OS that we are done work
|
| + // (if required). |task| also manages rescheduling behavior.
|
| + virtual void BeginBackgroundTask(
|
| + std::unique_ptr<ScopedBackgroundTask> task) = 0;
|
| +
|
| + // Called when a task must stop immediately due to system constraints. After
|
| + // this call completes, the system will reschedule the task based on whether
|
| + // SetNeedsReschedule has been called.
|
| + virtual void StopBackgroundTask(ScopedBackgroundTask* task) = 0;
|
| };
|
|
|
| } // namespace offline_pages
|
|
|