blob: 56094790f952afad07b2a9f03b377626f6b6b559 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/offline_pages/core/background/mark_attempt_deferred_task.h"
#include <utility>
#include "base/bind.h"
#include "components/offline_pages/core/offline_clock.h"
namespace offline_pages {
MarkAttemptDeferredTask::MarkAttemptDeferredTask(
RequestQueueStore* store,
int64_t request_id,
RequestQueueStore::UpdateCallback callback)
: UpdateRequestTask(store, request_id, std::move(callback)) {}
MarkAttemptDeferredTask::~MarkAttemptDeferredTask() {}
void MarkAttemptDeferredTask::UpdateRequestImpl(
UpdateRequestsResult read_result) {
if (!ValidateReadResult(read_result)) {
CompleteWithResult(std::move(read_result));
return;
}
// 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].MarkAttemptDeferred(OfflineTimeNow());
store()->UpdateRequests(
read_result.updated_items,
base::BindOnce(&MarkAttemptDeferredTask::CompleteWithResult,
GetWeakPtr()));
}
} // namespace offline_pages