| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_CLEANUP_TASK_H_ | |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_CLEANUP_TASK_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "components/offline_pages/background/request_queue_results.h" | |
| 13 #include "components/offline_pages/background/save_page_request.h" | |
| 14 #include "components/offline_pages/core/task.h" | |
| 15 | |
| 16 namespace offline_pages { | |
| 17 | |
| 18 class OfflinerPolicy; | |
| 19 class RequestCoordinatorEventLogger; | |
| 20 class RequestNotifier; | |
| 21 class RequestQueueStore; | |
| 22 | |
| 23 class CleanupTask : public Task { | |
| 24 public: | |
| 25 CleanupTask(RequestQueueStore* store, | |
| 26 OfflinerPolicy* policy, | |
| 27 RequestNotifier* notifier, | |
| 28 RequestCoordinatorEventLogger* logger); | |
| 29 ~CleanupTask() override; | |
| 30 | |
| 31 // TaskQueue::Task implementation, starts the async chain | |
| 32 void Run() override; | |
| 33 | |
| 34 private: | |
| 35 // Step 1. get results from the store | |
| 36 void GetRequests(); | |
| 37 | |
| 38 // Step 2. Prune stale requests | |
| 39 void Prune(bool success, | |
| 40 std::vector<std::unique_ptr<SavePageRequest>> requests); | |
| 41 | |
| 42 // Step 3. Send delete notifications for the expired requests. | |
| 43 void OnRequestsExpired(std::unique_ptr<UpdateRequestsResult> result); | |
| 44 | |
| 45 // Build a list of IDs whose request has expired. | |
| 46 void GetExpiredRequestIds( | |
| 47 std::vector<std::unique_ptr<SavePageRequest>> requests, | |
| 48 std::vector<int64_t>* expired_request_ids); | |
| 49 | |
| 50 // Member variables, all pointers are not owned here. | |
| 51 RequestQueueStore* store_; | |
| 52 OfflinerPolicy* policy_; | |
| 53 RequestNotifier* notifier_; | |
| 54 RequestCoordinatorEventLogger* event_logger_; | |
| 55 // Allows us to pass a weak pointer to callbacks. | |
| 56 base::WeakPtrFactory<CleanupTask> weak_ptr_factory_; | |
| 57 }; | |
| 58 | |
| 59 } // namespace offline_pages | |
| 60 | |
| 61 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_CLEANUP_TASK_H_ | |
| OLD | NEW |