OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/offline_pages/background/mark_attempt_started_task.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/bind.h" | |
10 #include "base/time/time.h" | |
11 | |
12 namespace offline_pages { | |
13 | |
14 MarkAttemptStartedTask::MarkAttemptStartedTask( | |
15 RequestQueueStore* store, | |
16 int64_t request_id, | |
17 const RequestQueueStore::UpdateCallback& callback) | |
18 : UpdateRequestTask(store, request_id, callback) {} | |
19 | |
20 MarkAttemptStartedTask::~MarkAttemptStartedTask() {} | |
21 | |
22 void MarkAttemptStartedTask::UpdateRequestImpl( | |
23 std::unique_ptr<UpdateRequestsResult> read_result) { | |
24 if (!ValidateReadResult(read_result.get())) { | |
25 CompleteWithResult(std::move(read_result)); | |
26 return; | |
27 } | |
28 | |
29 // It is perfectly fine to reuse the read_result->updated_items collection, as | |
30 // it is owned by this callback and will be destroyed when out of scope. | |
31 read_result->updated_items[0].MarkAttemptStarted(base::Time::Now()); | |
32 store()->UpdateRequests( | |
33 read_result->updated_items, | |
34 base::Bind(&MarkAttemptStartedTask::CompleteWithResult, GetWeakPtr())); | |
35 } | |
36 | |
37 } // namespace offline_pages | |
OLD | NEW |