| Index: components/offline_pages/background/mark_attempt_started_task.cc
|
| diff --git a/components/offline_pages/background/mark_attempt_started_task.cc b/components/offline_pages/background/mark_attempt_started_task.cc
|
| index ecd0507b8b9d56a46a1a14af8a13dc52f6fc6eae..f1a82ac82bd9f7b568225b545966ab2b2abc8b24 100644
|
| --- a/components/offline_pages/background/mark_attempt_started_task.cc
|
| +++ b/components/offline_pages/background/mark_attempt_started_task.cc
|
| @@ -4,8 +4,6 @@
|
|
|
| #include "components/offline_pages/background/mark_attempt_started_task.h"
|
|
|
| -#include <vector>
|
| -
|
| #include "base/bind.h"
|
| #include "base/time/time.h"
|
|
|
| @@ -15,29 +13,13 @@ MarkAttemptStartedTask::MarkAttemptStartedTask(
|
| RequestQueueStore* store,
|
| int64_t request_id,
|
| const RequestQueueStore::UpdateCallback& callback)
|
| - : store_(store),
|
| - request_id_(request_id),
|
| - callback_(callback),
|
| - weak_ptr_factory_(this) {}
|
| + : UpdateRequestTask(store, request_id, callback) {}
|
|
|
| MarkAttemptStartedTask::~MarkAttemptStartedTask() {}
|
|
|
| -void MarkAttemptStartedTask::Run() {
|
| - ReadRequest();
|
| -}
|
| -
|
| -void MarkAttemptStartedTask::ReadRequest() {
|
| - std::vector<int64_t> request_ids{request_id_};
|
| - store_->GetRequestsByIds(
|
| - request_ids, base::Bind(&MarkAttemptStartedTask::MarkAttemptStarted,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| -}
|
| -
|
| -void MarkAttemptStartedTask::MarkAttemptStarted(
|
| +void MarkAttemptStartedTask::UpdateRequestImpl(
|
| std::unique_ptr<UpdateRequestsResult> read_result) {
|
| - if (read_result->store_state != StoreState::LOADED ||
|
| - read_result->item_statuses.front().second != ItemActionStatus::SUCCESS ||
|
| - read_result->updated_items.size() != 1) {
|
| + if (!ValidateReadResult(read_result.get())) {
|
| CompleteWithResult(std::move(read_result));
|
| return;
|
| }
|
| @@ -45,15 +27,9 @@ void MarkAttemptStartedTask::MarkAttemptStarted(
|
| // It is perfectly fine to reuse the read_result->updated_items collection, as
|
| // it is owned by this callback and will be destroyed when out of scope.
|
| read_result->updated_items[0].MarkAttemptStarted(base::Time::Now());
|
| - store_->UpdateRequests(read_result->updated_items,
|
| - base::Bind(&MarkAttemptStartedTask::CompleteWithResult,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| -}
|
| -
|
| -void MarkAttemptStartedTask::CompleteWithResult(
|
| - std::unique_ptr<UpdateRequestsResult> result) {
|
| - callback_.Run(std::move(result));
|
| - TaskComplete();
|
| + store()->UpdateRequests(
|
| + read_result->updated_items,
|
| + base::Bind(&MarkAttemptStartedTask::CompleteWithResult, GetWeakPtr()));
|
| }
|
|
|
| } // namespace offline_pages
|
|
|