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_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 { | |
|
Dmitry Titov
2016/05/28 00:36:57
So the pattern of usage is:
requestPicker->Choose
Pete Williamson
2016/05/28 00:53:47
The RequestPicker is just a skeleton so far. Even
| |
| 15 public: | |
| 16 RequestPicker(RequestQueue* requestQueue, | |
| 17 RequestCoordinator::RequestPickedCallback picked_callback, | |
| 18 RequestCoordinator::RequestQueueEmptyCallback empty_callback); | |
| 19 | |
| 20 ~RequestPicker(); | |
| 21 | |
| 22 // Choose which request we should process next based on the current | |
| 23 // conditions, and call back to the RequestCoordinator when we have one. | |
| 24 void ChooseNextRequest(); | |
| 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 | |
|
dougarnett
2016/05/31 18:03:04
nit - period at end
| |
| 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 |