OLD | NEW |
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/core/background/remove_requests_task.h" | 5 #include "components/offline_pages/core/background/remove_requests_task.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 | 8 |
9 namespace offline_pages { | 9 namespace offline_pages { |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 CompleteEarly(ItemActionStatus::NOT_FOUND); | 28 CompleteEarly(ItemActionStatus::NOT_FOUND); |
29 return; | 29 return; |
30 } | 30 } |
31 | 31 |
32 store_->RemoveRequests(request_ids_, | 32 store_->RemoveRequests(request_ids_, |
33 base::Bind(&RemoveRequestsTask::CompleteWithResult, | 33 base::Bind(&RemoveRequestsTask::CompleteWithResult, |
34 weak_ptr_factory_.GetWeakPtr())); | 34 weak_ptr_factory_.GetWeakPtr())); |
35 } | 35 } |
36 | 36 |
37 void RemoveRequestsTask::CompleteEarly(ItemActionStatus status) { | 37 void RemoveRequestsTask::CompleteEarly(ItemActionStatus status) { |
38 // TODO(fgorski): store_->state() once implemented | |
39 std::unique_ptr<UpdateRequestsResult> result( | 38 std::unique_ptr<UpdateRequestsResult> result( |
40 new UpdateRequestsResult(StoreState::LOADED)); | 39 new UpdateRequestsResult(store_->state())); |
41 for (int64_t request_id : request_ids_) | 40 for (int64_t request_id : request_ids_) |
42 result->item_statuses.push_back(std::make_pair(request_id, status)); | 41 result->item_statuses.push_back(std::make_pair(request_id, status)); |
43 CompleteWithResult(std::move(result)); | 42 CompleteWithResult(std::move(result)); |
44 } | 43 } |
45 | 44 |
46 void RemoveRequestsTask::CompleteWithResult( | 45 void RemoveRequestsTask::CompleteWithResult( |
47 std::unique_ptr<UpdateRequestsResult> result) { | 46 std::unique_ptr<UpdateRequestsResult> result) { |
48 callback_.Run(std::move(result)); | 47 callback_.Run(std::move(result)); |
49 TaskComplete(); | 48 TaskComplete(); |
50 } | 49 } |
51 | 50 |
52 } // namespace offline_pages | 51 } // namespace offline_pages |
OLD | NEW |