Chromium Code Reviews| 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 int64_t current_request_id); | |
|
dougarnett
2016/12/05 21:27:45
Maybe active_request_id or excluded_request_id as
Pete Williamson
2016/12/06 00:25:38
Removed the parameter, since I took FGorski's sugg
| |
| 30 ~CleanupTask() override; | |
| 31 | |
| 32 // TaskQueue::Task implementation, starts the async chain | |
| 33 void Run() override; | |
| 34 | |
| 35 private: | |
| 36 // Step 1. get results from the store | |
| 37 void GetRequests(); | |
| 38 | |
| 39 // Step 2. Prune stale requests | |
| 40 void Prune(bool success, | |
| 41 std::vector<std::unique_ptr<SavePageRequest>> requests); | |
| 42 | |
| 43 // Step 3. Send delete notifications for the expired requests. | |
| 44 void OnRequestsExpired(std::unique_ptr<UpdateRequestsResult> result); | |
| 45 | |
| 46 // Build a list of IDs whose request has expired. | |
| 47 void GetExpiredRequestIds( | |
| 48 std::vector<std::unique_ptr<SavePageRequest>> requests, | |
| 49 std::vector<int64_t>* expired_request_ids); | |
| 50 | |
| 51 // Member variables, all pointers are not owned here. | |
| 52 RequestQueueStore* store_; | |
| 53 OfflinerPolicy* policy_; | |
| 54 RequestNotifier* notifier_; | |
| 55 RequestCoordinatorEventLogger* event_logger_; | |
| 56 int64_t current_request_id_; | |
| 57 // Allows us to pass a weak pointer to callbacks. | |
| 58 base::WeakPtrFactory<CleanupTask> weak_ptr_factory_; | |
| 59 }; | |
| 60 | |
| 61 } // namespace offline_pages | |
| 62 | |
| 63 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_CLEANUP_TASK_H_ | |
| OLD | NEW |