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_PICK_REQUEST_TASK_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_PICK_REQUEST_TASK_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_PICK_REQUEST_TASK_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_PICK_REQUEST_TASK_H_ |
7 | 7 |
| 8 #include <deque> |
8 #include <set> | 9 #include <set> |
9 | 10 |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "components/offline_pages/core/background/request_queue_results.h" | 12 #include "components/offline_pages/core/background/request_queue_results.h" |
12 #include "components/offline_pages/core/background/save_page_request.h" | 13 #include "components/offline_pages/core/background/save_page_request.h" |
13 #include "components/offline_pages/core/task.h" | 14 #include "components/offline_pages/core/task.h" |
14 | 15 |
15 namespace offline_pages { | 16 namespace offline_pages { |
16 | 17 |
17 class DeviceConditions; | 18 class DeviceConditions; |
(...skipping 18 matching lines...) Expand all Loading... |
36 | 37 |
37 // Callback to report available total and available queued request counts. | 38 // Callback to report available total and available queued request counts. |
38 typedef base::Callback<void(size_t, size_t)> RequestCountCallback; | 39 typedef base::Callback<void(size_t, size_t)> RequestCountCallback; |
39 | 40 |
40 PickRequestTask(RequestQueueStore* store, | 41 PickRequestTask(RequestQueueStore* store, |
41 OfflinerPolicy* policy, | 42 OfflinerPolicy* policy, |
42 RequestPickedCallback picked_callback, | 43 RequestPickedCallback picked_callback, |
43 RequestNotPickedCallback not_picked_callback, | 44 RequestNotPickedCallback not_picked_callback, |
44 RequestCountCallback request_count_callback, | 45 RequestCountCallback request_count_callback, |
45 DeviceConditions& device_conditions, | 46 DeviceConditions& device_conditions, |
46 const std::set<int64_t>& disabled_requests); | 47 const std::set<int64_t>& disabled_requests, |
| 48 std::deque<int64_t>& prioritized_requests); |
47 | 49 |
48 ~PickRequestTask() override; | 50 ~PickRequestTask() override; |
49 | 51 |
50 // TaskQueue::Task implementation, starts the async chain | 52 // TaskQueue::Task implementation, starts the async chain |
51 void Run() override; | 53 void Run() override; |
52 | 54 |
53 private: | 55 private: |
54 // Step 1. get the requests | 56 // Step 1. get the requests |
55 void GetRequests(); | 57 void GetRequests(); |
56 | 58 |
(...skipping 30 matching lines...) Expand all Loading... |
87 const SavePageRequest* right); | 89 const SavePageRequest* right); |
88 | 90 |
89 // Member variables, all pointers are not owned here. | 91 // Member variables, all pointers are not owned here. |
90 RequestQueueStore* store_; | 92 RequestQueueStore* store_; |
91 OfflinerPolicy* policy_; | 93 OfflinerPolicy* policy_; |
92 RequestPickedCallback picked_callback_; | 94 RequestPickedCallback picked_callback_; |
93 RequestNotPickedCallback not_picked_callback_; | 95 RequestNotPickedCallback not_picked_callback_; |
94 RequestCountCallback request_count_callback_; | 96 RequestCountCallback request_count_callback_; |
95 std::unique_ptr<DeviceConditions> device_conditions_; | 97 std::unique_ptr<DeviceConditions> device_conditions_; |
96 const std::set<int64_t>& disabled_requests_; | 98 const std::set<int64_t>& disabled_requests_; |
| 99 std::deque<int64_t>& prioritized_requests_; |
97 // Allows us to pass a weak pointer to callbacks. | 100 // Allows us to pass a weak pointer to callbacks. |
98 base::WeakPtrFactory<PickRequestTask> weak_ptr_factory_; | 101 base::WeakPtrFactory<PickRequestTask> weak_ptr_factory_; |
99 }; | 102 }; |
100 | 103 |
101 } // namespace offline_pages | 104 } // namespace offline_pages |
102 | 105 |
103 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_PICK_REQUEST_TASK_H_ | 106 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_PICK_REQUEST_TASK_H_ |
OLD | NEW |