Chromium Code Reviews| 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_BACKGROUND_REQUEST_PICKER_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 RequestPicker(RequestQueue* requestQueue, | 25 RequestPicker(RequestQueue* requestQueue, |
| 26 OfflinerPolicy* policy, | 26 OfflinerPolicy* policy, |
| 27 RequestNotifier* notifier); | 27 RequestNotifier* notifier); |
| 28 | 28 |
| 29 ~RequestPicker(); | 29 ~RequestPicker(); |
| 30 | 30 |
| 31 // Choose which request we should process next based on the current | 31 // Choose which request we should process next based on the current |
| 32 // conditions, and call back to the RequestCoordinator when we have one. | 32 // conditions, and call back to the RequestCoordinator when we have one. |
| 33 void ChooseNextRequest( | 33 void ChooseNextRequest( |
| 34 RequestCoordinator::RequestPickedCallback picked_callback, | 34 RequestCoordinator::RequestPickedCallback picked_callback, |
| 35 RequestCoordinator::RequestQueueEmptyCallback empty_callback, | 35 RequestCoordinator::RequestNotPickedCallback empty_callback, |
|
dougarnett
2016/09/01 18:24:13
not_picked_callback ?
Pete Williamson
2016/09/01 21:56:08
Done.
| |
| 36 DeviceConditions* device_conditions); | 36 DeviceConditions* device_conditions); |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 // Callback for the GetRequest results to be delivered. | 39 // Callback for the GetRequest results to be delivered. |
| 40 void GetRequestResultCallback(RequestQueue::GetRequestsResult result, | 40 void GetRequestResultCallback(RequestQueue::GetRequestsResult result, |
| 41 const std::vector<SavePageRequest>& results); | 41 const std::vector<SavePageRequest>& results); |
| 42 | 42 |
| 43 // Filter out requests that don't meet the current conditions. For instance, | 43 // Filter out requests that don't meet the current conditions. For instance, |
| 44 // if this is a predictive request, and we are not on WiFi, it should be | 44 // if this is a predictive request, and we are not on WiFi, it should be |
| 45 // ignored this round. | 45 // ignored this round. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 RequestNotifier* notifier_; | 85 RequestNotifier* notifier_; |
| 86 // Current conditions on the device | 86 // Current conditions on the device |
| 87 std::unique_ptr<DeviceConditions> current_conditions_; | 87 std::unique_ptr<DeviceConditions> current_conditions_; |
| 88 // True if we prefer less-tried requests | 88 // True if we prefer less-tried requests |
| 89 bool fewer_retries_better_; | 89 bool fewer_retries_better_; |
| 90 // True if we prefer requests submitted more recently | 90 // True if we prefer requests submitted more recently |
| 91 bool earlier_requests_better_; | 91 bool earlier_requests_better_; |
| 92 // Callback for when we are done picking a request to do next. | 92 // Callback for when we are done picking a request to do next. |
| 93 RequestCoordinator::RequestPickedCallback picked_callback_; | 93 RequestCoordinator::RequestPickedCallback picked_callback_; |
| 94 // Callback for when there are no more reqeusts to pick. | 94 // Callback for when there are no more reqeusts to pick. |
| 95 RequestCoordinator::RequestQueueEmptyCallback empty_callback_; | 95 RequestCoordinator::RequestNotPickedCallback not_picked_callback_; |
| 96 // Allows us to pass a weak pointer to callbacks. | 96 // Allows us to pass a weak pointer to callbacks. |
| 97 base::WeakPtrFactory<RequestPicker> weak_ptr_factory_; | 97 base::WeakPtrFactory<RequestPicker> weak_ptr_factory_; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace offline_pages | 100 } // namespace offline_pages |
| 101 | 101 |
| 102 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ | 102 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ |
| OLD | NEW |