| Index: components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc
|
| diff --git a/components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc b/components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc
|
| index 3c84ca5e937b4883abca3ce91a3b0e33a1b890bf..d85d19bebb2d47ef18dc4bb2fb026e803e492235 100644
|
| --- a/components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc
|
| +++ b/components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc
|
| @@ -4,10 +4,20 @@
|
|
|
| #include "components/offline_pages/core/prefetch/prefetch_dispatcher_impl.h"
|
|
|
| +#include "base/bind.h"
|
| +#include "base/task_runner.h"
|
| +#include "base/threading/thread_task_runner_handle.h"
|
| #include "url/gurl.h"
|
|
|
| namespace offline_pages {
|
|
|
| +namespace {
|
| +void DeleteBackgroundTaskHelper(
|
| + std::unique_ptr<PrefetchDispatcher::ScopedBackgroundTask> task) {
|
| + task.reset();
|
| +}
|
| +} // namespace
|
| +
|
| PrefetchDispatcherImpl::PrefetchDispatcherImpl() {}
|
|
|
| PrefetchDispatcherImpl::~PrefetchDispatcherImpl() = default;
|
| @@ -28,11 +38,16 @@ void PrefetchDispatcherImpl::RemovePrefetchURLsByClientId(
|
|
|
| void PrefetchDispatcherImpl::BeginBackgroundTask(
|
| std::unique_ptr<ScopedBackgroundTask> task) {
|
| - NOTIMPLEMENTED();
|
| + task_ = std::move(task);
|
| }
|
|
|
| -void PrefetchDispatcherImpl::StopBackgroundTask(ScopedBackgroundTask* task) {
|
| - NOTIMPLEMENTED();
|
| +void PrefetchDispatcherImpl::StopBackgroundTask(bool signaled_by_system) {
|
| + if (!task_)
|
| + return;
|
| + // Delay the deletion till the caller finishes.
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&DeleteBackgroundTaskHelper, base::Passed(std::move(task_))));
|
| }
|
|
|
| } // namespace offline_pages
|
|
|