Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Side by Side Diff: components/offline_pages/background/mark_attempt_completed_task.cc

Issue 2463713003: [Offline Pages] Converts MarkAttemptCompleted to use TaskQueue (Closed)
Patch Set: Fixed some lint Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/background/mark_attempt_started_task.h" 5 #include "components/offline_pages/background/mark_attempt_completed_task.h"
6
7 #include <utility>
Pete Williamson 2016/10/31 21:38:26 I wonder if <utility> should be added to mark_atte
dougarnett 2016/10/31 22:51:17 Done.
6 8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/time/time.h" 10 #include "base/time/time.h"
9 11
10 namespace offline_pages { 12 namespace offline_pages {
11 13
12 MarkAttemptStartedTask::MarkAttemptStartedTask( 14 MarkAttemptCompletedTask::MarkAttemptCompletedTask(
13 RequestQueueStore* store, 15 RequestQueueStore* store,
14 int64_t request_id, 16 int64_t request_id,
15 const RequestQueueStore::UpdateCallback& callback) 17 const RequestQueueStore::UpdateCallback& callback)
16 : UpdateRequestTask(store, request_id, callback) {} 18 : UpdateRequestTask(store, request_id, callback) {}
17 19
18 MarkAttemptStartedTask::~MarkAttemptStartedTask() {} 20 MarkAttemptCompletedTask::~MarkAttemptCompletedTask() {}
19 21
20 void MarkAttemptStartedTask::UpdateRequestImpl( 22 void MarkAttemptCompletedTask::UpdateRequestImpl(
21 std::unique_ptr<UpdateRequestsResult> read_result) { 23 std::unique_ptr<UpdateRequestsResult> read_result) {
22 if (!ValidateReadResult(read_result.get())) { 24 if (!ValidateReadResult(read_result.get())) {
23 CompleteWithResult(std::move(read_result)); 25 CompleteWithResult(std::move(read_result));
24 return; 26 return;
25 } 27 }
26 28
27 // It is perfectly fine to reuse the read_result->updated_items collection, as 29 // It is perfectly fine to reuse the read_result->updated_items collection, as
28 // it is owned by this callback and will be destroyed when out of scope. 30 // it is owned by this callback and will be destroyed when out of scope.
29 read_result->updated_items[0].MarkAttemptStarted(base::Time::Now()); 31 read_result->updated_items[0].MarkAttemptCompleted();
30 store()->UpdateRequests( 32 store()->UpdateRequests(
31 read_result->updated_items, 33 read_result->updated_items,
32 base::Bind(&MarkAttemptStartedTask::CompleteWithResult, GetWeakPtr())); 34 base::Bind(&MarkAttemptCompletedTask::CompleteWithResult, GetWeakPtr()));
33 } 35 }
34 36
35 } // namespace offline_pages 37 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698