| 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/background/change_requests_state_task.h" | 5 #include "components/offline_pages/background/change_requests_state_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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 CompleteEarly(ItemActionStatus::NOT_FOUND); | 59 CompleteEarly(ItemActionStatus::NOT_FOUND); |
| 60 return; | 60 return; |
| 61 } | 61 } |
| 62 | 62 |
| 63 store_->UpdateRequests(items_to_update, | 63 store_->UpdateRequests(items_to_update, |
| 64 base::Bind(&ChangeRequestsStateTask::UpdateCompleted, | 64 base::Bind(&ChangeRequestsStateTask::UpdateCompleted, |
| 65 weak_ptr_factory_.GetWeakPtr())); | 65 weak_ptr_factory_.GetWeakPtr())); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void ChangeRequestsStateTask::UpdateCompleted( | 68 void ChangeRequestsStateTask::UpdateCompleted( |
| 69 std::unique_ptr<UpdateRequestsResult> update_result) { | 69 std::unique_ptr<QueueResults::UpdateRequestsResult> update_result) { |
| 70 CompleteWithStatus(std::move(update_result), ItemActionStatus::NOT_FOUND); | 70 CompleteWithStatus(std::move(update_result), ItemActionStatus::NOT_FOUND); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void ChangeRequestsStateTask::CompleteEarly(ItemActionStatus status) { | 73 void ChangeRequestsStateTask::CompleteEarly(ItemActionStatus status) { |
| 74 // TODO(fgorski): store_->state() once implemented | 74 // TODO(fgorski): store_->state() once implemented |
| 75 std::unique_ptr<UpdateRequestsResult> result( | 75 std::unique_ptr<QueueResults::UpdateRequestsResult> result( |
| 76 new UpdateRequestsResult(StoreState::LOADED)); | 76 new QueueResults::UpdateRequestsResult(StoreState::LOADED)); |
| 77 CompleteWithStatus(std::move(result), status); | 77 CompleteWithStatus(std::move(result), status); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ChangeRequestsStateTask::CompleteWithStatus( | 80 void ChangeRequestsStateTask::CompleteWithStatus( |
| 81 std::unique_ptr<UpdateRequestsResult> result, | 81 std::unique_ptr<QueueResults::UpdateRequestsResult> result, |
| 82 ItemActionStatus status) { | 82 ItemActionStatus status) { |
| 83 // Mark items as not found, if they are still in the request IDs set. | 83 // Mark items as not found, if they are still in the request IDs set. |
| 84 for (int64_t request_id : request_ids_) | 84 for (int64_t request_id : request_ids_) |
| 85 result->item_statuses.push_back(std::make_pair(request_id, status)); | 85 result->item_statuses.push_back(std::make_pair(request_id, status)); |
| 86 callback_.Run(std::move(result)); | 86 callback_.Run(std::move(result)); |
| 87 TaskComplete(); | 87 TaskComplete(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace offline_pages | 90 } // namespace offline_pages |
| OLD | NEW |