| 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 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_CLEANUP_TASK_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_CLEANUP_TASK_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_CLEANUP_TASK_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_CLEANUP_TASK_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <memory> | 9 #include <memory> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "components/offline_pages/core/background/offliner_policy_utils.h" |
| 12 #include "components/offline_pages/core/background/request_queue_results.h" | 14 #include "components/offline_pages/core/background/request_queue_results.h" |
| 13 #include "components/offline_pages/core/background/save_page_request.h" | 15 #include "components/offline_pages/core/background/save_page_request.h" |
| 14 #include "components/offline_pages/core/task.h" | 16 #include "components/offline_pages/core/task.h" |
| 15 | 17 |
| 16 namespace offline_pages { | 18 namespace offline_pages { |
| 17 | 19 |
| 18 class OfflinerPolicy; | 20 class OfflinerPolicy; |
| 19 class RequestCoordinatorEventLogger; | 21 class RequestCoordinatorEventLogger; |
| 20 class RequestNotifier; | 22 class RequestNotifier; |
| 21 class RequestQueueStore; | 23 class RequestQueueStore; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 void GetRequests(); | 38 void GetRequests(); |
| 37 | 39 |
| 38 // Step 2. Prune stale requests | 40 // Step 2. Prune stale requests |
| 39 void Prune(bool success, | 41 void Prune(bool success, |
| 40 std::vector<std::unique_ptr<SavePageRequest>> requests); | 42 std::vector<std::unique_ptr<SavePageRequest>> requests); |
| 41 | 43 |
| 42 // Step 3. Send delete notifications for the expired requests. | 44 // Step 3. Send delete notifications for the expired requests. |
| 43 void OnRequestsExpired(std::unique_ptr<UpdateRequestsResult> result); | 45 void OnRequestsExpired(std::unique_ptr<UpdateRequestsResult> result); |
| 44 | 46 |
| 45 // Build a list of IDs whose request has expired. | 47 // Build a list of IDs whose request has expired. |
| 46 void GetExpiredRequestIds( | 48 void PopulateExpiredRequestIdsAndReasons( |
| 47 std::vector<std::unique_ptr<SavePageRequest>> requests, | 49 std::vector<std::unique_ptr<SavePageRequest>> requests); |
| 48 std::vector<int64_t>* expired_request_ids); | |
| 49 | 50 |
| 50 // Member variables, all pointers are not owned here. | 51 // Member variables, all pointers are not owned here. |
| 51 RequestQueueStore* store_; | 52 RequestQueueStore* store_; |
| 52 OfflinerPolicy* policy_; | 53 OfflinerPolicy* policy_; |
| 53 RequestNotifier* notifier_; | 54 RequestNotifier* notifier_; |
| 54 RequestCoordinatorEventLogger* event_logger_; | 55 RequestCoordinatorEventLogger* event_logger_; |
| 56 |
| 57 // Holds a map of expired request IDs and respective expiration reasons. |
| 58 std::map<int64_t, OfflinerPolicyUtils::RequestExpirationStatus> |
| 59 expired_request_ids_and_reasons_; |
| 60 |
| 55 // Allows us to pass a weak pointer to callbacks. | 61 // Allows us to pass a weak pointer to callbacks. |
| 56 base::WeakPtrFactory<CleanupTask> weak_ptr_factory_; | 62 base::WeakPtrFactory<CleanupTask> weak_ptr_factory_; |
| 57 }; | 63 }; |
| 58 | 64 |
| 59 } // namespace offline_pages | 65 } // namespace offline_pages |
| 60 | 66 |
| 61 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_CLEANUP_TASK_H_ | 67 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_CLEANUP_TASK_H_ |
| OLD | NEW |