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_REQUEST_PICKER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "components/offline_pages/background/request_coordinator.h" |
| 10 #include "components/offline_pages/background/request_queue.h" |
| 11 |
| 12 namespace offline_pages { |
| 13 |
| 14 class RequestPicker { |
| 15 public: |
| 16 RequestPicker(RequestQueue* requestQueue); |
| 17 |
| 18 ~RequestPicker(); |
| 19 |
| 20 // Choose which request we should process next based on the current |
| 21 // conditions, and call back to the RequestCoordinator when we have one. |
| 22 void ChooseNextRequest( |
| 23 RequestCoordinator::RequestPickedCallback picked_callback, |
| 24 RequestCoordinator::RequestQueueEmptyCallback empty_callback); |
| 25 |
| 26 private: |
| 27 // Callback for the GetRequest results to be delivered. |
| 28 void GetRequestResultCallback(RequestQueue::GetRequestsResult result, |
| 29 const std::vector<SavePageRequest>& results); |
| 30 |
| 31 // unowned pointer to the request queue. |
| 32 RequestQueue* queue_; |
| 33 // Callback for when we are done picking a request to do next. |
| 34 RequestCoordinator::RequestPickedCallback picked_callback_; |
| 35 // Callback for when there are no more reqeusts to pick. |
| 36 RequestCoordinator::RequestQueueEmptyCallback empty_callback_; |
| 37 // Allows us to pass a weak pointer to callbacks. |
| 38 base::WeakPtrFactory<RequestPicker> weak_ptr_factory_; |
| 39 }; |
| 40 |
| 41 } // namespace offline_pages |
| 42 |
| 43 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_PICKER_H_ |
OLD | NEW |