| 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/cleanup_task.h" | 5 #include "components/offline_pages/core/background/cleanup_task.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "components/offline_pages/core/background/offliner_policy.h" | 9 #include "components/offline_pages/core/background/offliner_policy.h" |
| 10 #include "components/offline_pages/core/background/offliner_policy_utils.h" | 10 #include "components/offline_pages/core/background/offliner_policy_utils.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Get the expired requests to be removed from the queue. | 49 // Get the expired requests to be removed from the queue. |
| 50 std::vector<int64_t> expired_request_ids; | 50 std::vector<int64_t> expired_request_ids; |
| 51 GetExpiredRequestIds(std::move(requests), &expired_request_ids); | 51 GetExpiredRequestIds(std::move(requests), &expired_request_ids); |
| 52 | 52 |
| 53 // Continue processing by handling expired requests, if any. | 53 // Continue processing by handling expired requests, if any. |
| 54 if (expired_request_ids.size() == 0) { | 54 if (expired_request_ids.size() == 0) { |
| 55 TaskComplete(); | 55 TaskComplete(); |
| 56 return; | 56 return; |
| 57 } | 57 } |
| 58 | 58 |
| 59 // TODO(petewil): Add UMA saying why we remove them | 59 // TODO(petewil): Add UMA saying why we remove them. Round trip the reason |
| 60 // TODO(petewil): Round trip the reason for deleting through the RQ | 60 // for deleting through the RQ callbacks. crbug.com/705115. |
| 61 store_->RemoveRequests(expired_request_ids, | 61 store_->RemoveRequests(expired_request_ids, |
| 62 base::Bind(&CleanupTask::OnRequestsExpired, | 62 base::Bind(&CleanupTask::OnRequestsExpired, |
| 63 weak_ptr_factory_.GetWeakPtr())); | 63 weak_ptr_factory_.GetWeakPtr())); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void CleanupTask::OnRequestsExpired( | 66 void CleanupTask::OnRequestsExpired( |
| 67 std::unique_ptr<UpdateRequestsResult> result) { | 67 std::unique_ptr<UpdateRequestsResult> result) { |
| 68 RequestNotifier::BackgroundSavePageResult save_page_result( | 68 RequestNotifier::BackgroundSavePageResult save_page_result( |
| 69 RequestNotifier::BackgroundSavePageResult::EXPIRED); | 69 RequestNotifier::BackgroundSavePageResult::EXPIRED); |
| 70 for (const auto& request : result->updated_items) { | 70 for (const auto& request : result->updated_items) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 95 if (status != OfflinerPolicyUtils::RequestExpirationStatus::VALID && | 95 if (status != OfflinerPolicyUtils::RequestExpirationStatus::VALID && |
| 96 request->request_state() != SavePageRequest::RequestState::OFFLINING) { | 96 request->request_state() != SavePageRequest::RequestState::OFFLINING) { |
| 97 // TODO(petewil): Push both request and reason, will need to change type | 97 // TODO(petewil): Push both request and reason, will need to change type |
| 98 // of list to pairs. | 98 // of list to pairs. |
| 99 expired_request_ids->push_back(request->request_id()); | 99 expired_request_ids->push_back(request->request_id()); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace offline_pages | 104 } // namespace offline_pages |
| OLD | NEW |